Zh/Entity Hierarchy (parenting): Difference between revisions
(otherlang2) |
(重新创建了汉化页面,持续汉化中) |
||
Line 1: | Line 1: | ||
{{otherlang2 | {{otherlang2 | ||
| | |ru=Entity_Hierarchy_(parenting):ru | ||
|jp= | |jp=Entity_Hierarchy_(parenting):jp | ||
| | |zh-cn=Entity Hierarchy_(parenting):zh-cn | ||
}} | }} | ||
本简体中文页面由 [[User:GlrWere|Gloria]] 汉化(W.I.P.)。 | |||
当一组实体“绑定(Parented)”到一起时,整个层级的实体就能严格一致地运动,表现得就像是一个单独的物理对象。每个子实体(child-entity)都会跟随父实体(parent)的运动。 | |||
最简单的例子是,将一个 [[light_dynamic]] 实体绑定到一个实体类型为[[prop_physics|物理实体]]的台灯模型上,这样光源就如同台灯的一部分一样跟随着台灯模型运动。 | |||
绑定关系是在子实体的[[HammerObjectPropertiesDialog|对象属性]]中设定的。父实体则无法控制谁绑定了它。这种形式导致了文档中不得不使用反身动词的形式进行说明,例如“必须被绑定到”“将子实体绑定到父实体”“实体必须有父实体”这类神奇的表述。 | |||
*注:“parented”是“parent”的过去分词形式,直译为“以xxx为双亲”。个人建议翻译成“绑定”,符合原意且易于说明和理解。 | |||
只有某些特定实体可以设置父实体。例如,[[prop_physics|物理实体]]不可以,因为它自身就是一个物理对象(但任何实体都能作为其它实体的父实体,如果被添加到了'parentname'属性栏中,尽管不都能正常工作)。这种情况下,可以使用 [[prop_dynamic]] 或 [[prop_dynamic_override]] 作为替代,或是使用 [[info_constraint_anchor]] 实体以连接成[[constraint|物理约束系统]]。 | |||
* '''Offset(偏移量)''' 指的是子实体与父实体的距离(包括任意角度的偏移量)。当应用了偏移量属性后,子实体将会平行于父实体运动,并且在父实体旋转时绕着父实体中心“公转”,只有 ''SetParentAttachment'' 事件输入能够''修改''偏移量;它会将子实体立即“传送”并维持在父实体的绑定点上。 | |||
* '''碰撞箱''' :子实体的自身碰撞在绑定后会被忽略。它能够穿过墙或其它的固体对象。 | |||
* 当父实体收到 '''Killed''' 事件并被移除时,它当前的所有子实体都将被从游戏中移除。 | |||
==Parentname属性== | |||
为了在两个实体间创建父子关联,将子实体的 '''parentname属性''' 设置为父实体的'''[[targetname|实体名称]]'''。 | |||
* 维持偏移量。 {{bug|[[Counter-Strike: Source|反恐精英:起源]] 中部分实体的父实体属性存在异常。取而代之,可以使用 [[logic_auto]] 实体,在地图开始时调用SetParent事件。}}{{bug|在Linux专用服务器上的 [[Half-Life 2: Deathmatch|半条命2:死亡竞赛]]中,子实体有时会丢失绑定。因此,强烈建议使用 [[logic_auto]] 实体,并在输出中添加“<code>OnMapSpawn child SetParent parent</code>”(其中:child 代指子实体名称,parent 代指父实体名称)}} | |||
* 此外,一个 [[attachment]] 点可以通过设置 '''parent,attachment''' 来进行设定。它的作用就像 '''SetParentAttachmentMaintainOffset''' 一样。 | |||
== SetParent事件 == | |||
你可以在子实体上[[Inputs_and_Outputs|触发]]一个 '''SetParent 输入'''事件来更改绑定关联。 | |||
* Use the ''targetname'' of the new parent as the input parameter to make the child follow the new parent. | |||
* If you leave the parameter blank, it has the same effect as the ''ClearParent'' input (see below). | |||
* Maintains offset. | |||
== SetParentAttachment == | |||
{{note|Entities must be parented before being sent this input. Use at least a 0.01 second delay between ''SetParent'' and ''SetParentAttachment'' inputs.}} | |||
You can also [[Inputs_and_Outputs|fire]] a '''SetParentAttachment input''' at the child-entity to attach it to a specific [[attachment]] point on its parent. The parameter is the name of the attachment point. | |||
* The Child instantly ''teleports'' to the attachment point. This is the only method which ''does not'' maintain the offset. | |||
== SetParentAttachmentMaintainOffset == | |||
{{note|Entities must be parented before being sent this input. Use at least a 0.01 second delay between ''SetParent'' and ''SetParentAttachmentMaintainOffset '' inputs.}} | |||
You can also [[Inputs_and_Outputs|fire]] a '''SetParentAttachmentMaintainOffset input''' at the child-entity to attach it to a specific attachment point on it's parent. This works exactly the same as the '''SetParentAttachment input''' except the child-entity will maintain it's relative position to and distance from the parent at the time it is attached. | |||
* Maintains offset, but the Child shadows/orbits the attachment point position instead of the parent's [[EntityOrigin]]. | |||
{{note|You can parent an entity directly to an attachment point by putting a comma to separate the parent's name and the attachment point. The offset will be maintain <br /> | |||
Example : Combine_Dead_Ragdoll,anim_attachment_RH }} | |||
== ClearParent == | |||
You can also [[Inputs_and_Outputs|fire]] a '''ClearParent input''' at the child-entity to remove its child-parent relationship. This simply 'unparents' or 'detaches' the child-entity from its current parent, so the child is then free to move (or not) independently of its former parent. | |||
== KillHierarchy == | |||
{{note|This is the only ''movement hierarchy''-related input that can be fired at the '''parent'''-entity.}} | |||
If you [[Inputs_and_Outputs|fire]] a '''KillHierarchy input''' at the parent-entity, it Removes the parent-entity ''and'' all of its children from the world. | |||
* If you fire a '''Kill input''' at the parent-entity, it also Removes the parent-entity and its children from the world ... ? | |||
{{Bug|If you have a point_spotlight child of another entity, and you kill the parent entity without removing the point_spotlight using an input, it will spawn in the center of the map (0,0,0) facing north.}} | |||
==FollowEntity()== | |||
Programmers can use <code>[[FollowEntity()]]</code> to control parenting. | |||
[[Category:Level Design]] | |||
==Tutorials about PARENT (Russian)== | |||
Lessons created by [https://vk.com/project_source Project-S] | |||
[https://www.youtube.com/watch?v=e-78OU52VLw All about Parent (Всё о Parent)] |
Revision as of 05:56, 27 May 2018
Template:Otherlang2 本简体中文页面由 Gloria 汉化(W.I.P.)。
当一组实体“绑定(Parented)”到一起时,整个层级的实体就能严格一致地运动,表现得就像是一个单独的物理对象。每个子实体(child-entity)都会跟随父实体(parent)的运动。
最简单的例子是,将一个 light_dynamic 实体绑定到一个实体类型为物理实体的台灯模型上,这样光源就如同台灯的一部分一样跟随着台灯模型运动。
绑定关系是在子实体的对象属性中设定的。父实体则无法控制谁绑定了它。这种形式导致了文档中不得不使用反身动词的形式进行说明,例如“必须被绑定到”“将子实体绑定到父实体”“实体必须有父实体”这类神奇的表述。
- 注:“parented”是“parent”的过去分词形式,直译为“以xxx为双亲”。个人建议翻译成“绑定”,符合原意且易于说明和理解。
只有某些特定实体可以设置父实体。例如,物理实体不可以,因为它自身就是一个物理对象(但任何实体都能作为其它实体的父实体,如果被添加到了'parentname'属性栏中,尽管不都能正常工作)。这种情况下,可以使用 prop_dynamic 或 prop_dynamic_override 作为替代,或是使用 info_constraint_anchor 实体以连接成物理约束系统。
- Offset(偏移量) 指的是子实体与父实体的距离(包括任意角度的偏移量)。当应用了偏移量属性后,子实体将会平行于父实体运动,并且在父实体旋转时绕着父实体中心“公转”,只有 SetParentAttachment 事件输入能够修改偏移量;它会将子实体立即“传送”并维持在父实体的绑定点上。
- 碰撞箱 :子实体的自身碰撞在绑定后会被忽略。它能够穿过墙或其它的固体对象。
- 当父实体收到 Killed 事件并被移除时,它当前的所有子实体都将被从游戏中移除。
Parentname属性
为了在两个实体间创建父子关联,将子实体的 parentname属性 设置为父实体的实体名称。
- 维持偏移量。
错误:反恐精英:起源 中部分实体的父实体属性存在异常。取而代之,可以使用 logic_auto 实体,在地图开始时调用SetParent事件。 [todo tested in ?]
错误:在Linux专用服务器上的 半条命2:死亡竞赛中,子实体有时会丢失绑定。因此,强烈建议使用 logic_auto 实体,并在输出中添加“
OnMapSpawn child SetParent parent
”(其中:child 代指子实体名称,parent 代指父实体名称) [todo tested in ?] - 此外,一个 attachment 点可以通过设置 parent,attachment 来进行设定。它的作用就像 SetParentAttachmentMaintainOffset 一样。
SetParent事件
你可以在子实体上触发一个 SetParent 输入事件来更改绑定关联。
- Use the targetname of the new parent as the input parameter to make the child follow the new parent.
- If you leave the parameter blank, it has the same effect as the ClearParent input (see below).
- Maintains offset.
SetParentAttachment

You can also fire a SetParentAttachment input at the child-entity to attach it to a specific attachment point on its parent. The parameter is the name of the attachment point.
- The Child instantly teleports to the attachment point. This is the only method which does not maintain the offset.
SetParentAttachmentMaintainOffset

You can also fire a SetParentAttachmentMaintainOffset input at the child-entity to attach it to a specific attachment point on it's parent. This works exactly the same as the SetParentAttachment input except the child-entity will maintain it's relative position to and distance from the parent at the time it is attached.
- Maintains offset, but the Child shadows/orbits the attachment point position instead of the parent's EntityOrigin.

Example : Combine_Dead_Ragdoll,anim_attachment_RH
ClearParent
You can also fire a ClearParent input at the child-entity to remove its child-parent relationship. This simply 'unparents' or 'detaches' the child-entity from its current parent, so the child is then free to move (or not) independently of its former parent.
KillHierarchy

If you fire a KillHierarchy input at the parent-entity, it Removes the parent-entity and all of its children from the world.
- If you fire a Kill input at the parent-entity, it also Removes the parent-entity and its children from the world ... ?

FollowEntity()
Programmers can use FollowEntity()
to control parenting.
Tutorials about PARENT (Russian)
Lessons created by Project-S