Zh/Entity Hierarchy (parenting): Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(重新创建了汉化页面,持续汉化中)
No edit summary
Line 16: Line 16:
只有某些特定实体可以设置父实体。例如,[[prop_physics|物理实体]]不可以,因为它自身就是一个物理对象(但任何实体都能作为其它实体的父实体,如果被添加到了'parentname'属性栏中,尽管不都能正常工作)。这种情况下,可以使用 [[prop_dynamic]] 或 [[prop_dynamic_override]] 作为替代,或是使用 [[info_constraint_anchor]] 实体以连接成[[constraint|物理约束系统]]。
只有某些特定实体可以设置父实体。例如,[[prop_physics|物理实体]]不可以,因为它自身就是一个物理对象(但任何实体都能作为其它实体的父实体,如果被添加到了'parentname'属性栏中,尽管不都能正常工作)。这种情况下,可以使用 [[prop_dynamic]] 或 [[prop_dynamic_override]] 作为替代,或是使用 [[info_constraint_anchor]] 实体以连接成[[constraint|物理约束系统]]。


* '''Offset(偏移量)''' 指的是子实体与父实体的距离(包括任意角度的偏移量)。当应用了偏移量属性后,子实体将会平行于父实体运动,并且在父实体旋转时绕着父实体中心“公转”,只有 ''SetParentAttachment'' 事件输入能够''修改''偏移量;它会将子实体立即“传送”并维持在父实体的绑定点上。
* '''Offset(偏移量)''' 指的是子实体与父实体的距离(包括任意角度的偏移量)。当应用了偏移量属性后,子实体将会平行于父实体运动,并且在父实体旋转时绕着父实体原点“公转”,只有 ''SetParentAttachment'' 事件输入能够''修改''偏移量;它会将子实体立即“传送”并维持在父实体的绑定点上。


* '''碰撞箱''' :子实体的自身碰撞在绑定后会被忽略。它能够穿过墙或其它的固体对象。
* '''碰撞箱''' :子实体的自身碰撞在绑定后会被忽略。它能够穿过墙或其它的固体对象。
Line 25: Line 25:
为了在两个实体间创建父子关联,将子实体的 '''parentname属性''' 设置为父实体的'''[[targetname|实体名称]]'''。
为了在两个实体间创建父子关联,将子实体的 '''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 代指父实体名称)}}
* 维持偏移量。 {{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''' 一样。
* 此外,一个 [[attachment|附着点(attachment point)]]可以通过设置 '''parent,attachment''' 来进行设定。它的作用就像 '''SetParentAttachmentMaintainOffset''' 一样。


== SetParent事件 ==
== SetParent输入事件 ==
你可以在子实体上[[Inputs_and_Outputs|触发]]一个 '''SetParent 输入'''事件来更改绑定关联。
你可以在子实体上[[Inputs_and_Outputs|触发]]一个 '''SetParent输入'''事件来更改绑定关联。
* Use the ''targetname'' of the new parent as the input parameter to make the child follow the new parent.
* ''targetname'' 设置成新的父实体,作为 SetParent 的输入参数,来把子实体绑定到新的父实体上。
* If you leave the parameter blank, it has the same effect as the ''ClearParent'' input (see below).
* 如果参数一栏为空,则它的效果与 ''ClearParent'' 输出事件相同(见下方)。
* Maintains offset.
* 能够保持偏移量。


== SetParentAttachment ==
== SetParentAttachment输入事件 ==
{{note|Entities must be parented before being sent this input. Use at least a 0.01 second delay between ''SetParent'' and ''SetParentAttachment'' inputs.}}
{{note:zh-cn|在使用这个输入事件前,实体必须先完成绑定。在 ''SetParent'' ''SetParentAttachment'' 两个输入事件之间必须至少有0.01秒的延时。}}
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.
你还可以在子实体上[[Inputs_and_Outputs|触发]]一个 '''SetParentAttachment输入事件''',将它绑定到父实体的某个特定的[[attachment|附着点]]上。参数为附着点的名称。
* The Child instantly ''teleports'' to the attachment point. This is the only method which ''does not'' maintain the offset.
* 子实体会立即“传送”到附着点的位置。这是唯一一种无法保持偏移量的方法。


== SetParentAttachmentMaintainOffset ==
== SetParentAttachmentMaintainOffset输入事件 ==
{{note|Entities must be parented before being sent this input. Use at least a 0.01 second delay between ''SetParent'' and ''SetParentAttachmentMaintainOffset '' inputs.}}
{{note:zh-cn|在使用这个输入事件前,实体必须先完成绑定。在 ''SetParent'' ''SetParentAttachment'' 两个输入事件之间设置至少0.01秒的延时。}}
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.
你还可以在子实体上[[Inputs_and_Outputs|触发]]一个 '''SetParentAttachmentMaintainOffset输入事件''' 将它绑定到父实体的某个特定的[[attachment|附着点]]上。这部分的作用与 '''SetParentAttachment输入事件''' 完全一致,区别在于这个方法将会保持子实体绑定到父实体时的偏移量不变。
* Maintains offset, but the Child shadows/orbits the attachment point position instead of the parent's [[EntityOrigin]].
* 能够保持偏移量不变,但子实体将会跟随附着点运动、旋转而不是父实体的[[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 />
{{note:zh-cn|可以用逗号分隔父实体名称、附着点名称的形式将子实体直接绑定到父实体的附着点上,偏移量将会维持不变。<br />
  Example : Combine_Dead_Ragdoll,anim_attachment_RH }}
  例如 : Combine_Dead_Ragdoll,anim_attachment_RH }}


== ClearParent ==
== 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.
你还可以在子实体上[[Inputs_and_Outputs|触发]]一个 '''ClearParent输入事件''' 来解除父子实体的绑定。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 ==
== KillHierarchy ==

Revision as of 10:12, 27 May 2018

Template:Otherlang2 本简体中文页面由 Gloria 汉化(W.I.P.)。


当一组实体“绑定(Parented)”到一起时,整个层级的实体就能严格一致地运动,表现得就像是一个单独的物理对象。每个子实体(child-entity)都会跟随父实体(parent)的运动。

最简单的例子是,将一个 light_dynamic 实体绑定到一个实体类型为物理实体的台灯模型上,这样光源就如同台灯的一部分一样跟随着台灯模型运动。

绑定关系是在子实体的对象属性中设定的。父实体则无法控制谁绑定了它。这种形式导致了文档中不得不使用反身动词的形式进行说明,例如“必须被绑定到”“将子实体绑定到父实体”“实体必须有父实体”这类神奇的表述。

  • 注:“parented”是“parent”的过去分词形式,直译为“以xxx为双亲”。个人建议翻译成“绑定”,符合原意且易于说明和理解。

只有某些特定实体可以设置父实体。例如,物理实体不可以,因为它自身就是一个物理对象(但任何实体都能作为其它实体的父实体,如果被添加到了'parentname'属性栏中,尽管不都能正常工作)。这种情况下,可以使用 prop_dynamicprop_dynamic_override 作为替代,或是使用 info_constraint_anchor 实体以连接成物理约束系统

  • Offset(偏移量) 指的是子实体与父实体的距离(包括任意角度的偏移量)。当应用了偏移量属性后,子实体将会平行于父实体运动,并且在父实体旋转时绕着父实体原点“公转”,只有 SetParentAttachment 事件输入能够修改偏移量;它会将子实体立即“传送”并维持在父实体的绑定点上。
  • 碰撞箱 :子实体的自身碰撞在绑定后会被忽略。它能够穿过墙或其它的固体对象。
  • 当父实体收到 Killed 事件并被移除时,它当前的所有子实体都将被从游戏中移除。

Parentname属性

为了在两个实体间创建父子关联,将子实体的 parentname属性 设置为父实体的实体名称

  • 维持偏移量。
    Icon-Bug.png错误:反恐精英:起源 中部分实体的父实体属性存在异常。取而代之,可以使用 logic_auto 实体,在地图开始时调用SetParent事件。  [todo tested in ?]
    Icon-Bug.png错误:在Linux专用服务器上的 半条命2:死亡竞赛中,子实体有时会丢失绑定。因此,强烈建议使用 logic_auto 实体,并在输出中添加“OnMapSpawn child SetParent parent”(其中:child 代指子实体名称,parent 代指父实体名称)  [todo tested in ?]
  • 此外,一个 附着点(attachment point)可以通过设置 parent,attachment 来进行设定。它的作用就像 SetParentAttachmentMaintainOffset 一样。

SetParent输入事件

你可以在子实体上触发一个 SetParent输入事件来更改绑定关联。

  • targetname 设置成新的父实体,作为 SetParent 的输入参数,来把子实体绑定到新的父实体上。
  • 如果参数一栏为空,则它的效果与 ClearParent 输出事件相同(见下方)。
  • 能够保持偏移量。

SetParentAttachment输入事件

Template:Note:zh-cn 你还可以在子实体上触发一个 SetParentAttachment输入事件,将它绑定到父实体的某个特定的附着点上。参数为附着点的名称。

  • 子实体会立即“传送”到附着点的位置。这是唯一一种无法保持偏移量的方法。

SetParentAttachmentMaintainOffset输入事件

Template:Note:zh-cn 你还可以在子实体上触发一个 SetParentAttachmentMaintainOffset输入事件 将它绑定到父实体的某个特定的附着点上。这部分的作用与 SetParentAttachment输入事件 完全一致,区别在于这个方法将会保持子实体绑定到父实体时的偏移量不变。

  • 能够保持偏移量不变,但子实体将会跟随附着点运动、旋转而不是父实体的实体原点

Template:Note:zh-cn

ClearParent输入事件

你还可以在子实体上触发一个 ClearParent输入事件 来解除父子实体的绑定。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.png注意:This is the only movement hierarchy-related input that can be fired at the parent-entity.

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 ... ?
Icon-Bug.png错误: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.  [todo tested in ?]

FollowEntity()

Programmers can use FollowEntity() to control parenting.

Tutorials about PARENT (Russian)

Lessons created by Project-S

All about Parent (Всё о Parent)