这篇条目有关 Source引擎。如需详情,点击这里。

prop_physics

From Valve Developer Community
< Zh
Jump to navigation Jump to search
English (en)中文 (zh)Translate (Translate)
类层级
CPhysicsProp
CBreakableProp
CBaseProp
CBaseAnimating
CBaseEntity
props.cpp

prop_physics是一个模型实体,可在所有的 起源 起源 游戏中使用。 用于向世界添加刚性的VPhysics(en)物理模拟模型(en)

prop_physics唯一需要的值是一个模型路径。只要该模型是physics-enabled(en),地图启动时就会从中加载正确的数据。可以使用"Override Parameters"键值更改任何嵌入的物理数据。

prop_physics这样的物理对象可以被parented(en),虽然默认FGD(en)中没有且可能无法正常工作。建议改用动态物理约束。参见Physics Entity Overview(en)获取更多信息。

Tip.png提示:多人游戏地图应使用prop_physics_multiplayer,它能更好地与碰撞预测代码配合工作。
Tip.png提示:要创建关节物理对象,请使用prop_ragdoll
AltNames.pngAltNames: 此实体也绑定到 physics_prop。 生成时类名总是会被改为prop_physics
Icon-Important.png重要:求生之路系列求生之路系列 求生之路系列中,如果使用的模型足够小,此实体会自动变为客户端实体。如果该实体需要参与I/O交互,请确保勾选Force server-side标志。

一致性

待完善: 将此部分移至独立文章。

在处理Source引擎提供的众多道具模型时,一致性成为一大问题。从玩家角度看,物体交互性应在游戏/模组的所有关卡中保持一致,因为如果道具行为只在特定情况下不同,玩家往往难以解谜或快速决策。为确保这一点,道具的游戏相关数据存储在模型本身中。

例如,假设游戏中有一个始终不可移动的板条箱,玩家已习惯其静态特性。但在某一特定情况下,这个板条箱需要被移动才能继续游戏。这会引起大量困扰和混乱,因此保持一致性十分必要。开发者通常会使用不同的皮肤或模型来传达行为差异并保持一致性。

本应进行物理模拟的模型(椅子、桌子、木板等)如果被放置为prop_staticprop_dynamic实体会自行移除(仍可通过prop_dynamic_override实体作为静态道具使用)。其他游戏相关数据,如质量、"health"、gib数量及模型等也都存储在道具模型中。

存储方法及设置指南可在模型QC文件的Prop Data(en)部分找到。

Keyvalues

参见:  Generic Keyvalues, Inputs and Outputs available to all entities
Name(en) (targetname) <target_source>
其他实体引用该实体的目标名称。

BasePropPhysics:

Physics Impact Damage Scale (physdamagescale) <浮点型(en)>
乘以物理冲击受到的伤害。0表示为了向后兼容而禁用该功能。
Impact damage type (Damagetype) <布尔值(en)>
如果为true(1),伤害类型为锐器且对象可以切割其他物体。
Damaging it Doesn't Push It (nodamageforces) <布尔值(en)>
是否对实体造成伤害时会施加力。
Scale Factor For Inertia (inertiascale) <浮点型(en)>
缩放物体的角质量。用于hack角度伤害和碰撞响应。
证实:实际上不影响惯性
Mass Scale (massscale) <浮点型(en)>
物体质量的乘数。
Override Parameters (overridescript) <字符串(en)>
通常是嵌入在模型中(en)的物理键值列表。格式为key,value,key,value,…
Health Level to Override Motion (damagetoenablemotion) <整数(en)>
如果指定,此对象将以禁用运动开始。一旦其health低于此指定值,将启用运动。
Physics Impact Force to Override Motion (forcetoenablemotion) <浮点型(en)>
如果指定,此对象将以禁用运动开始。任何施加力大于此值的冲击将启用运动。

BreakableProp:

Explosion Damage (ExplodeDamage) <浮点型(en)>
If non-zero, when this entity breaks it will create an explosion that causes the specified amount of damage. See also Explosion Radius.
Explosion Radius (ExplodeRadius) <浮点型(en)>
If non-zero, when this entity breaks it will create an explosion with a radius of the specified amount. See also Explosion Damage.
Sound to make when punted (puntsound) <sound(en)> (存在于自 半衰期2:第一章 以来)
Sound to make when punted by gravity gun.
Break Model Message (BreakModelMessage) <字符串(en)> (存在于 起源2013 之中)
"If set, will use this break model message instead of the normal break behavior."

Breakable (common):

Performance Mode (PerformanceMode) <choices>
Used to limit the amount of gibs produced when this entity breaks, for performance reasons.
Choices
  • 0: Normal
  • 1: No Gibs
  • 2: Full Gibs on All Platforms (Xbox 360, PS3, etc)
  • 3: Reduced gibs
Min Damage to Hurt (minhealthdmg) <整数(en)>
If a single hit to the object doesn't do at least this much damage, the prop won't take any of the damage it attempted to give.
Pressure Delay (PressureDelay) <浮点型(en)>
Seconds to delay breaking from pressure. Allows creaking/groaning sounds to play.
Health (health) <整数(en)>
How close to breaking the object is.
Maximum Health (max_health) <整数(en)>
Health cannot exceed this amount.
Physics Impact Damage Scale (physdamagescale) <浮点型(en)>
Multiplier for damage amount when this entity is hit by a physics object. With a value of 0 the entity will take no damage from physics.
Breakable By (BreakableType) <choices> (存在于 求生之路系列求生之路系列 之中)
Who can break this?
  • 0: Everyone
  • 1: All Infected
  • 2: Only Tanks

GMODSandbox:

Allow Physics Gun (gmod_allowphysgun) <布尔值(en)> (存在于 Garry's Mod 之中)
If set, players cannot use Physics Gun on this entity.
Sandbox Tool Whitelist (gmod_allowtools) <字符串(en)> (存在于 Garry's Mod 之中)
If set, only given tools can be used on this entity. You need to supply the tool class names, the names of the .lua files of those tools. This also includes the context menu properties!

CBaseAnimating:

World Model (model) <model(en)>
The model this entity should appear as. 128-character limit.
Skin (skin) <整数(en)>
Some models have multiple skins. This value selects from the index, starting with 0. May be overridden by game code.
Tip.png提示:Hammer's model browser automatically updates this value if you use it to view different skins.
Model Scale (modelscale) <浮点型(en)> (存在于自 异形丛生 以来) (也存在于 起源2013 之中)
A multiplier for the size of the model.
Tip.png提示:In Hammer++ Hammer++ with a prop selected in 3D view, hold Ctrl and scroll the mouse wheel to change the modelscale in increments of 0.5. Holding Shift will scale it in smaller increments of 0.05.
Bodygroup (body / SetBodyGroup) <整数(en)>
Some models have multiple submodels. This value selects from the index, starting with 0. May be overridden by animations and/or game code.
Note.png注意:If both body and SetBodyGroup are present (even if set to 0), body will be prioritized.


Lighting Origin (lightingorigin) <target_destination>
Select an entity (not info_lighting!) from which to sample lighting and cubemaps instead of the entity's $illumposition.

阴影:

Disable Shadows (disableshadows) <布尔值(en)>
防止该实体生成廉价的渲染到纹理的阴影,或如果实体是 prop_static 的光照贴图阴影。不影响影子映射。
禁用接收阴影 (disablereceiveshadows) <布尔值(en)>
防止该实体接收动态阴影。
Shadow Cast Distance (shadowcastdist) <整数(en)> 不存在于FGD!
设置实体投射动态阴影的距离。0 表示从 shadow_control 实体开始的默认距离。
Disable Shadow Depth (disableshadowdepth) <布尔值(en)> (存在于自 传送门2 以来)
用于禁用此实体的阴影深度(用于投影纹理)的渲染。
Disable flashlight (disableflashlight) <布尔值(en)> (存在于自 传送门2 以来)
用于禁用此实体的投影纹理照明和阴影。
Projected Texture Cache (shadowdepthnocache) <integer choices(en)> (存在于自 传送门2 以来)
用于提示投影纹理系统缓存此实体的阴影体积是否足够,或改为强制每帧渲染。
选项
  • 0 : 默认
  • 1 : 无缓存 - 每帧渲染
  • 2 : 缓存 - 只渲染一次
Render in Fast Reflections (drawinfastreflection) <布尔值(en)> (存在于自 传送门2 以来)
If enabled, this entity will render in fast water reflections (i.e. when a water material specifies $reflectonlymarkedentities) and in the world impostor pass.

Flags

BasePropPhysics:

Start Asleep(en) : [1]
Don't take physics damage : [2]
不承受物理伤害
Debris(en) : [4]
不与玩家或其他碎片(en)碰撞。
Motion Disabled(en) : [8]
初始禁用运动直到收到EnableMotion指令。
Enable motion when grabbed by gravity gun : [64]
重力枪(en)抓取时启用运动
Not affected by rotor wash(en) : [128]
不受旋翼下洗流影响
Generate output on +use : [256]
是否生成OnPlayerUse输出
Prevent pickup : [512]
禁止拾取
Prevent motion enable on player bump : [1024]
防止玩家碰撞时启用运动
Has Attached Ragdolls : [2048] 不存在于FGD!
游戏会在附着布娃娃时设置此标志,道具移动时分离布娃娃
Note.png注意:仅用于具有"impale"prop interaction(en)(PROPINTER_PHYSGUN_FIRST_IMPALE)的道具,如半衰期2中的鱼叉(不同于crossbow(en)箭,后者使用不同方法固定布娃娃)。最好不要手动设置此标志。
Debris with trigger(en) interaction : [4096]
可与触发器交互的碎片
Note.png注意:单独使用时不会启用碎片行为。需要与Debris标志PROPINTER_PHYSGUN_CREATE_FLARE道具交互一起使用。
Force server-side : [8192]
仅多人游戏有效;参见sv_pushaway_clientside_size
Icon-Bug.png错误:求生之路系列求生之路系列中,当可破坏道具设置Force server-side标志时,其下方的导航区域会被标记为MOB_ONLY  (tested in: l4d2)
Radius Pickup : [16384] 不存在于FGD!
使物体更容易抓取
Gravity gun can ALWAYS pick up. No matter what. : [1048576]
允许此道具被标准gravity gun(en)拾取,即使其$mass(en)超过physcannon_maxmass(默认250kg)。在没有重力枪的游戏中无效。
No Collisions : [2097152] 不存在于FGD!
生成时禁用碰撞
Gib : [4194304] 不存在于FGD!
如果是碎片,卡在碰撞中时移除
Attempt to override gib with the character gib system : [4194304] (存在于 黑山 之中)
尝试用角色gib系统覆盖gib
Zombies(en) can't swat : [8388608] (存在于 Mapbase 之中)
僵尸在寻找拍打对象时会忽略此道具

BreakableProp:

Break on Touch : [16]
Break on Pressure : [32]
Will break after being stood on for PressureDelay seconds.
Note.png注意:Some models will break instantly if this is or isn't set. (e.g. militiawindow02_breakable.mdl, window_industrial.mdl)

Inputs

BasePropPhysics:

Sleep
告诉道具停止移动。任何物理力(不包括重力和水的浮力)都会使对象恢复移动。当对象没有物理力保持清醒且不再有明显移动时,也会自动进入睡眠。
Wake
如果对象被告知睡眠,告诉它重新开始移动。
DisableMotion
告诉对象完全停止移动。没有任何物理力会重新启用运动,甚至Wake也不行。
EnableMotion
如果对象的运动已被完全禁用,告诉它恢复正常移动。如果对象正在Sleep,这也会Wake它。
DisableFloating
如果对象在水中通常会漂浮,告诉它不要漂浮。似乎没有办法重新启用漂浮行为,但编程实现此功能的方法应该相当简单(CALLBACK_DO_FLUID_SIMULATION)。

BreakableProp:

Break
Breaks the breakable.
SetHealth <整数(en)>
Sets a new value for the breakable's health. If the breakable's health reaches zero it will break.
AddHealth <整数(en)>
Adds health to the breakable.
RemoveHealth <整数(en)>
Removes health from the breakable.
physdamagescale <浮点型(en)>
Sets Physics Impact Damage Scale. 0 means this feature is disabled for backwards compatibility.
EnablePhyscannonPickup
Makes the breakable able to picked up by the gravity gun.
DisablePhyscannonPickup
Makes the breakable not able to picked up by the gravity gun.
EnablePuntSound  (存在于自 半衰期2:第一章 以来)
Allow this prop from playing its Punt Sound sound when punted by the gravity gun.
DisablePuntSound  (存在于自 半衰期2:第一章 以来)
Prevent this prop from playing its Punt Sound sound when punted by the gravity gun.

Outputs

OnMotionEnabled
!activator = !caller = this entity
当道具的运动被启用时触发,无论是通过Health Level to Override Motion键值还是EnableMotion输入。
OnAwakened
!activator = !caller = this entity
当道具被唤醒时触发(当它睡着时施加了力,或调用了Wake输入)。
OnOutOfWorld
!activator = !caller = this entity
每当检测到对象在世界之外时触发。具体来说,它检查对象是否在世界bounding box(en)之外,或者对象是否在任何基本方向上以超过2000单位/秒的速度移动。
OnPlayerUse
!activator = !caller = this entity
当玩家+use道具时触发。
Note.png注意:此输出(但与其它拾取相关的输出不同)仅在设置了Generate output on +USE生成标志时才会触发。
OnPhysGunDrop
!activator = the player
!caller = this entity
当玩家放下道具时触发(无论是通过+use还是重力枪)。
OnPlayerPickup
!activator = the player
!caller = this entity
当玩家通过+use或重力枪(在Half-Life 2中)拾取道具时触发。
OnPhysGunOnlyPickup  (存在于自 半衰期2 以来)
!activator = the player
!caller = this entity
当玩家专门用重力枪拾取道具时触发。
OnHitByTank  (存在于 求生之路2 之中)
!activator = !caller = this entity
当道具被Tank boss感染者击中时触发。

BreakableProp:

OnBreak
!activator = entity that breaks the object
!caller = this entity
Fired when this object breaks.
OnHealthChanged <浮点型(en)>
!activator = entity that caused the health change
!caller = this entity
Fired whenever the health of the breakable has increased or decreased. This output automatically puts the new health amount as a decimal percent (e.g. 45% = 0.45) into the parameter box for inputs, if the mapper does not override the parameter with something else.
OnTakeDamage
!activator = entity that caused the damage
!caller = this entity
Fired when damage is taken.
OnPhysCannonAnimatePreStarted
!activator = none
!caller = this entity
Fired when prop starts its ACT_PHYSCANNON_ANIMATE_PRE activity. Caused by the object being picked up by the gravity gun.
OnPhysCannonAnimatePullStarted
!activator = none
!caller = this entity
Fired when prop has started its ACT_PHYSCANNON_ANIMATE activity. ACT_PHYSCANNON_ANIMATE_PRE plays once, then ACT_PHYSCANNON_ANIMATE starts looping.
OnPhysCannonDetach
!activator = none
!caller = this entity
Fired when prop has started its ACT_PHYSCANNON_DETACH activity (caused by the gravity gun ripping it from a wall).
OnPhysCannonAnimatePostStarted
!activator = none
!caller = this entity
Fired when prop has started its ACT_PHYSCANNON_ANIMATE_POST activity (caused by the player letting the prop go from the gravity gun).
OnPhysCannonPullAnimFinished
!activator = none
!caller = this entity
Fired when prop has finished all gravity gun-related animations.

参见