Prop ragdoll: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Add internal names of keyval keys)
m (added language bar and updated template usage.)
Line 1: Line 1:
: ''For details on creating a ragdoll, see [[$collisionjoints]].''
{{lang|Prop ragdoll}}
{{seealso|For details on creating a ragdoll, see {{ent|$collisionjoints}}.}}


[[File:prop_ragdoll.jpg|thumb|prop_ragdoll can interact with dynamic objects, unlike death ragdolls.]]
[[File:prop_ragdoll.jpg|thumb|prop_ragdoll can interact with dynamic objects, unlike death ragdolls.]]


{{base_point|prop_ragdoll}} It is a [[VPhysics]] [[Wikipedia:Ragdoll physics|ragdoll]]. Ragdolls are collections of physics objects constrained together to simulate a jointed object like a dead body. They are very [[expensive]] to simulate.
{{point ent|prop_ragdoll}} It is a [[VPhysics]] [[Wikipedia:Ragdoll physics|ragdoll]]. Ragdolls are collections of physics objects constrained together to simulate a jointed object like a dead body. They are very [[expensive]] to simulate.


{{warning|This entity generates server-side ragdolls, which collide with everything but produce very large amounts of network traffic. Network traffic can be significantly reduced by making the ragdoll start asleep, disabling motion and disabling collisions with dynamic objects ({{not in FGD}} add "solid" keyvalue with value of 0) and only enabling motion when necessary.}}
{{warning|This entity generates server-side ragdolls, which collide with everything but produce very large amounts of network traffic. Network traffic can be significantly reduced by making the ragdoll start asleep, disabling motion and disabling collisions with dynamic objects ({{not in FGD}} add "solid" keyvalue with value of 0) and only enabling motion when necessary.}}
{{bug|Setting a custom pose via Hammer and making the ragdoll start asleep will make the rendering box fail to update. Making the ragdoll wake for a single frame when spawned and then sleeping it will fix this issue.}}
{{bug|Setting a custom pose via Hammer and making the ragdoll start asleep will make the rendering box fail to update. Making the ragdoll wake for a single frame when spawned and then sleeping it will fix this issue.}}
{{bug|In [[Portal 2]], ragdolls cannot pass through portals. This often occurs in Portal as well}}
{{bug|{{Portal2}} ragdolls cannot pass through portals. This often occurs in {{Portal}} as well.}}


{{altnames|name1=physics_prop_ragdoll}}
{{altnames|name1=physics_prop_ragdoll}}
Line 15: Line 16:
See also [[Prop Types Overview]].
See also [[Prop Types Overview]].


==Death ragdolls/ragdoll transformation==
==Death Ragdolls/Ragdoll Transformation==
 
When a NPC/player dies or an entity receives the <code>BecomeRagdoll</code> input, it normally creates a '''client-side''' ragdoll and copies most of its animation and visual data to it. Unlike server-side <tt>prop_ragdoll</tt>s, these client-side ragdolls are handled completely on a per-client basis and are ''much'' cheaper and simpler than their server-side counterparts, at the expense of being virtually nonexistent on the server, being inconsistent across client perspectives, and only colliding with entities that have physics objects on the client (e.g. {{ent|worldspawn}}).
When a NPC/player dies or an entity receives the <code>BecomeRagdoll</code> input, it normally creates a '''client-side''' ragdoll and copies most of its animation and visual data to it. Unlike server-side prop_ragdolls, these client-side ragdolls are handled completely on a per-client basis and are ''much'' cheaper and simpler than their server-side counterparts, at the expense of being virtually nonexistent on the server, being inconsistent across client perspectives, and only colliding with entities that have physics objects on the client (e.g. {{ent|worldspawn}}).


However, a NPC will become a server-side ragdoll while it's under any of the following conditions:
However, a NPC will become a server-side ragdoll while it's under any of the following conditions:
* The NPC is inside the volume of a [[trigger_serverragdoll]]
* The NPC is inside the volume of a {{ent|trigger_serverragdoll}}
* The NPC is killed by a vehicle in singleplayer
* The NPC is killed by a vehicle in singleplayer
* The [[weapon_physcannon|gravity gun]] is supercharged
* The [[weapon_physcannon|gravity gun]] is supercharged
* The NPC dies on fire while in [[env_global|Alyx darkness mode]]
* The NPC dies on fire while in [[env_global|Alyx darkness mode]]
* The NPC is a vital ally (e.g. {{ent|npc_alyx}})
* The NPC is a vital ally (e.g., {{ent|npc_alyx}})
These server-side death ragdolls will collide with physics objects and beyond, like any prop_ragdoll, but they are marked as debris and do not collide with each other. They do not collide with ''themselves'' either, unlike client-side ragdolls. This is believed to be intentional behavior to reduce performance/networking costs.
These server-side death ragdolls will collide with physics objects and beyond, like any <tt>prop_ragdoll</tt>, but they are marked as debris and do not collide with each other. They do not collide with ''themselves'' either, unlike client-side ragdolls. This is believed to be intentional behavior to reduce performance/networking costs.
{{note|Most of this list ''theoretically'' applies to players as well, although that hasn't been tested.}}
{{note|Most of this list ''theoretically'' applies to players as well, although that hasn't been tested.}}


Line 35: Line 35:
{{KV|Body|intn=body|int|Specifies which [[$bodygroup|body group]] should be used.|nofgd=1}}
{{KV|Body|intn=body|int|Specifies which [[$bodygroup|body group]] should be used.|nofgd=1}}
{{KV|Override Animation|intn=angleOverride|string|Filled in by the engine via [[wc_update_entity]]. Do not edit by hand except to clear.}}
{{KV|Override Animation|intn=angleOverride|string|Filled in by the engine via [[wc_update_entity]]. Do not edit by hand except to clear.}}
{{ScrollBox|
{{KV DXLevelChoice}}
{{KV SystemLevelChoice}}
{{KV Studiomodel}}
{{KV Angles}}
{{KV BaseFadeProp}}
{{KV Targetname}}
{{KV GMOD}}
{{KV GMOD}}
}}
{{KV BaseAnimating|noscroll=0}}
 
{{KV BaseEntity|noscroll=0}}
==Flags==
==Flags==
* 4 : Debris - Don't collide with the player or other debris
{{fl|4|Debris|Don't collide with the player or other debris}}
* 8192 : Allow Dissolve
{{fl|8192|Allow Dissolve}}
* 16384 : Motion Disabled
{{fl|16384|Motion Disabled}}
* 32768 : Allow stretch
{{fl|32768|Allow stretch}}
* 65536 : Start asleep
{{fl|65536|Start asleep}}


==Inputs==
==Inputs==
{{IO|StartRagdollBoogie|Begins ragdoll boogie effect for 5 seconds.{{bugfix|This input is actually supposed to use a parameter for how long the ragdoll should boogie, but it uses the wrong field type in the data description.|In <code>CRagdollProp</code>'s data description, find <code>DEFINE_INPUTFUNC( FIELD_VOID, "StartRagdollBoogie", InputStartRadgollBoogie )</code> and replace <code>FIELD_VOID</code> with <code>FIELD_FLOAT</code>.|code}}}}
{{IO|StartRagdollBoogie|Begins ragdoll boogie effect for 5 seconds.{{bugfix|This input is actually supposed to use a parameter for how long the ragdoll should boogie, but it uses the wrong field type in the data description.|In <code>CRagdollProp</code>'s data description, find <code>DEFINE_INPUTFUNC( FIELD_VOID, "StartRagdollBoogie", InputStartRadgollBoogie )</code> and replace <code>FIELD_VOID</code> with <code>FIELD_FLOAT</code>.|code}}}}
{{IO|EnableMotion, DisableMotion|Enable/disable physics simulation.}}
{{IO|EnableMotion, DisableMotion|Enable/disable physics simulation.}}
{{IO|FadeAndRemove|Fade out then remove (kill) self. Parameter override <nowiki>=</nowiki> duration of fade.|since=EP2}}
{{IO|FadeAndRemove|Fade out then remove (kill) self. Parameter override <nowiki>=</nowiki> duration of fade.|since={{hl2ep2}}}}
{{IO|Ignite|Set on fire.|nofgd=1}}
{{I BaseAnimating|noscroll=0}}
{{IO|SetBodyGroup|Change the current [[$bodygroup|body group]].|nofgd=1}}
{{I BaseEntity|noscroll=0}}
{{ScrollBox|
{{I RenderFields}}
{{I Studiomodel}}
{{I Targetname}}
}}
 
==Outputs==
==Outputs==
{{O Targetname}}
{{O BaseAnimating|portal2=1}}
{{O BaseEntity|l4d=1}}

Revision as of 17:49, 20 October 2022

English (en)中文 (zh)Translate (Translate)
See also:  For details on creating a ragdoll, see $collisionjoints.
prop_ragdoll can interact with dynamic objects, unlike death ragdolls.

Template:Point ent It is a VPhysics ragdoll. Ragdolls are collections of physics objects constrained together to simulate a jointed object like a dead body. They are very expensive to simulate.

Warning.pngWarning:This entity generates server-side ragdolls, which collide with everything but produce very large amounts of network traffic. Network traffic can be significantly reduced by making the ragdoll start asleep, disabling motion and disabling collisions with dynamic objects (!FGD add "solid" keyvalue with value of 0) and only enabling motion when necessary.
Icon-Bug.pngBug:Setting a custom pose via Hammer and making the ragdoll start asleep will make the rendering box fail to update. Making the ragdoll wake for a single frame when spawned and then sleeping it will fix this issue.  [todo tested in ?]
Icon-Bug.pngBug:Portal 2 ragdolls cannot pass through portals. This often occurs in Portal as well.  [todo tested in ?]
AltNames.pngAltNames: This entity is also tied to physics_prop_ragdoll.
C++ In code, it is represented by theCRagdollPropclass, defined in thephysics_prop_ragdoll.cppfile.

See also Prop Types Overview.

Death Ragdolls/Ragdoll Transformation

When a NPC/player dies or an entity receives the BecomeRagdoll input, it normally creates a client-side ragdoll and copies most of its animation and visual data to it. Unlike server-side prop_ragdolls, these client-side ragdolls are handled completely on a per-client basis and are much cheaper and simpler than their server-side counterparts, at the expense of being virtually nonexistent on the server, being inconsistent across client perspectives, and only colliding with entities that have physics objects on the client (e.g. worldspawn).

However, a NPC will become a server-side ragdoll while it's under any of the following conditions:

These server-side death ragdolls will collide with physics objects and beyond, like any prop_ragdoll, but they are marked as debris and do not collide with each other. They do not collide with themselves either, unlike client-side ragdolls. This is believed to be intentional behavior to reduce performance/networking costs.

Note.pngNote:Most of this list theoretically applies to players as well, although that hasn't been tested.
Warning.pngWarning:While most of the relevant animation/visual data is copied to ragdolls, some fields, like fade distances, are not transferred.
Cpp.pngCode:This can be modified at CBaseAnimating::CopyAnimationDataFrom() in baseanimating.cpp for server-side ragdolls and C_BaseAnimating::CreateRagdollCopy() in c_baseanimating.cpp for client-side ragdolls.

Keyvalues

sequence ([todo internal name (i)]) <integer> !FGD
The ragdoll will be moved to the first frame of this animation before VPhysics takes over.
Icon-Bug.pngBug:Doesn't function.  [todo tested in ?]
Body (body) <integer> !FGD
Specifies which body group should be used.
Override Animation (angleOverride) <string>
Filled in by the engine via wc_update_entity. Do not edit by hand except to clear.

GMODSandbox:

Allow Physics Gun (gmod_allowphysgun) <boolean> (only in Garry's Mod)
If set, players cannot use Physics Gun on this entity.
Sandbox Tool Whitelist (gmod_allowtools) <string> (only in 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!
Note.pngNote:Content moved to Rendering and studio model related KIO/Keyvalues for continuation of page history

Flags

Debris : [4]
Don't collide with the player or other debris
Allow Dissolve : [8192]
Motion Disabled : [16384]
Allow stretch : [32768]
Start asleep : [65536]

Inputs

StartRagdollBoogie
Begins ragdoll boogie effect for 5 seconds.
Icon-Bug.pngBug:This input is actually supposed to use a parameter for how long the ragdoll should boogie, but it uses the wrong field type in the data description.  [todo tested in ?]
Cpp.pngCode Fix:In CRagdollProp's data description, find DEFINE_INPUTFUNC( FIELD_VOID, "StartRagdollBoogie", InputStartRadgollBoogie ) and replace FIELD_VOID with FIELD_FLOAT.
EnableMotion, DisableMotion
Enable/disable physics simulation.
FadeAndRemove  (in all games since Half-Life 2: Episode Two)
Fade out then remove (kill) self. Parameter override = duration of fade.
Note.pngNote:Content moved to Rendering and studio model related KIO/Inputs for continuation of page history

Outputs

Note.pngNote:Content moved to Rendering and studio model related KIO/Outputs for continuation of page history