This article's documentation is for anything that uses the Source engine. Click here for more information.

prop_physics

From Valve Developer Community
Jump to: navigation, search
Class hierarchy
CPhysicsProp
CBreakableProp
CBaseProp
CBaseAnimating
CBaseEntity
props.cpp

prop_physics is a point entity available in all Source Source games. It is used to add rigid, VPhysics-simulated models to the world.

The only value required for prop_physics to work is a path to a model. As long as that model is physics-enabled, the correct data will be loaded from it when the map starts. It is possible to change any embedded physics data with the "Override Parameters" keyvalue.

Physics objects like prop_physics can be parented, though it is not in the default FGD and may not function correctly. It is recommended to instead use dynamic physics constraints. See Physics Entity Overview for more information.

Tip.pngTip:Multiplayer maps should use prop_physics_multiplayer, which works better with the collision prediction code.
Do not use prop_physics_respawnable; it will crash the server if destroyed by a trigger_hurt.
Tip.pngTip:To create a jointed physics object, use prop_ragdoll.
AltNames.pngAltNames: This entity is also tied to physics_prop. The classname is always changed to prop_physics on spawn.

Consistency

Todo: Move this section to its own article.

Consistency becomes a large problem when dealing with the many prop models that the Source engine provides. From a player's perspective, object interactivity should remain consistent across all the levels of your game / mod, as players will often have a hard time solving puzzles or making quick decisions if the prop's behaviour is different in only one specific instance. To enforce this, the game-related data of props is stored within the model itself.

For example, imagine you have a crate that is immovable for the entirety of your game and the player has gotten used to that crate being static. However, in one specific instance, this crate is not moveable and required to be moved to proceed. This can cause lots of irritation and confusion, and therefore is why consistency is necessary. Oftentimes, developers will use different skins or models to convey differences in behaviour and keep consistency.

Models that are meant to be physically simulated (chairs, tables, wooden planks, etc) will remove themselves if they are placed as prop_static or prop_dynamic entities (You can still use these as static props using the entity prop_dynamic_override). Other game-related data, such as mass, "health", gib amount & models, and so on are all stored inside the prop model as well.

The method by which they are stored, and guidelines for how to set it up, can be found in the Prop Data section of the model's QC file.

Keyvalues

Name (targetname) <string>
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

BasePropPhysics:

Physics Impact Damage Scale (physdamagescale) <float>
Multiplies damage received from physics impacts. 0 means the feature is disabled for backwards compatibility.
Impact damage type (Damagetype) <boolean>
If true (1), damage type is sharp and the object can slice others.
Damaging it Doesn't Push It (nodamageforces) <boolean>
Whether damaging the entity applies force to it.
Scale Factor For Inertia (inertiascale) <float>
Scales the angular mass of an object. Used to hack angular damage and collision response.
Confirm:Doesn't actually affect inertia?
Mass Scale (massscale) <float>
Multiplier for the object's mass.
Override Parameters (overridescript) <string>
A list of physics keyvalues that are usually embedded in the model. Format is key,value,key,value,….
Health Level to Override Motion (damagetoenablemotion) <integer>
If specified, this object will start with motion disabled. Once its health has dropped below this specified amount, it will enable motion.
Physics Impact Force to Override Motion (forcetoenablemotion) <float>
If specified, this object will start motion disabled. Any impact that imparts a force greater than this value will enable motion.

BreakableProp:

Explosion Damage (ExplodeDamage) <float>
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) <float>
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> (in all games since Half-Life 2: Episode One)
Sound to make when punted by gravity gun.
Break Model Message (BreakModelMessage) <string>
"If set, will use this break model message instead of the normal break behavior."
Confirm:Is this new with Source SDK 2013...? It isn't in Alien Swarm or 2007 code but is in 2013. New with L4D?

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) <integer>
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) <float>
Seconds to delay breaking from pressure. Allows creaking/groaning sounds to play.
Health (health) <integer>
How close to breaking the object is.
Maximum Health (max_health) <integer>
Health cannot exceed this amount.
Physics Impact Damage Scale (physdamagescale) <float>
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> (only in Left 4 Dead series)
Who can break this?
  • 0: Everyone
  • 1: All Infected
  • 2: Only Tanks

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!

Studiomodel:

World Model (model) <string>
The model this entity should appear as. 128-character limit.
Skin (skin) <integer>
Some models have multiple skins. This value selects from the index, starting with 0.
Tip.pngTip:Hammer's model browser automatically updates this value if you use it to view different skins.
Model Scale (modelscale) <float> (in all games since Alien Swarm) (also in Source 2013)
A multiplier for the size of the model.
Tip.pngTip: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 or SetBodyGroup) <integer>
Some models have multiple submodels. This value selects from the index, starting with 0. May be overridden by animations and/or game code.
Note.pngNote:If both body and SetBodyGroup are present (even if set to 0), body will be prioritized.
Lighting Origin (lightingorigin) <targetname>
Select an entity (not info_lighting!) from which to sample lighting instead of the entity's origin or $illumposition.

Shadow:

Disable Shadows (disableshadows) <boolean>
Prevents the entity from creating cheap render-to-texture shadows, or lightmap shadows if the entity is a prop_static. Does not affect shadow mapping.
Disable Receiving Shadows (disablereceiveshadows) <boolean>
Prevent the entity from receiving dynamic shadows on itself.
Shadow Cast Distance (shadowcastdist) <integer> !FGD
Sets how far the entity casts dynamic shadows. 0 means default distance from the shadow_control entity.
Disable Shadow Depth (disableshadowdepth) <boolean> (in all games since Portal 2)
Used to disable rendering into shadow depth (for projected textures) for this entity.
Disable flashlight (disableflashlight) <boolean> (in all games since Portal 2)
Used to disable projected texture lighting and shadows on this entity.
Projected Texture Cache (shadowdepthnocache) <integer choices> (in all games since Portal 2)
Used to hint projected texture system whether it is sufficient to cache shadow volume of this entity or to force render it every frame instead.
Choices
  • 0 : Default
  • 1 : No cache - render every frame
  • 2 : Cache it - render only once
Render in Fast Reflections (drawinfastreflection) <boolean> (in all games since Portal 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 : [1]
  •  Don't take physics damage : [2]
  •  Debris : [4]
       Don't collide with the player or other debris.
  •  Motion Disabled : [8]
       Starts with motion disabled until sent EnableMotion.
  •  Enable motion when grabbed by gravity gun : [64]
  •  Not affected by rotor wash : [128]
  •  Generate output on +use : [256]
       Whether to generate OnPlayerUse output
  •  Prevent pickup : [512]
  •  Prevent motion enable on player bump. : [1024]
  •  Has Attached Ragdolls : [2048] !FGD
       Set by the game when ragdolls are attached, detaches them when prop moves
Note.pngNote:Used solely by props with the "impale" prop interaction (PROPINTER_PHYSGUN_FIRST_IMPALE), such as the harpoons in Half-Life 2 (not to be confused with the crossbow bolts, which use a different method for pinning ragdolls). It is best not to assign this spawnflag manually.
  •  Debris with trigger interaction. : [4096]
Note.pngNote:Does not enable Debris behavior on its own. Needs to be used together with the Debris spawnflag or with the PROPINTER_PHYSGUN_CREATE_FLARE prop interaction.
Icon-Bug.pngBug:In Left 4 Dead series when breakable prop has Force server-side flag set then nav areas under it will be marked MOB_ONLY  (tested in: l4d2)
  •  Radius Pickup : [16384] !FGD
       Makes objects easier to grab
  •  Gravity gun can ALWAYS pick up. No matter what. : [1048576]
  •  No Collisions : [2097152] !FGD
       Disable collisions on spawn
  •  Gib : [4194304] !FGD
       If debris, remove when stuck in a collision
  •  Attempt to override gib with the character gib system : [4194304] (only in Black Mesa)
  •  Zombies can't swat : [8388608] (only in Mapbase)
       Zombies will ignore this prop when looking for an object to swat at the enemy.

BreakableProp:

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

Inputs

BasePropPhysics:

Sleep
Tell the prop to quit moving. Any physics forces (excluding gravity and water buoyancy) will cause the object to resume moving as usual. Sleeping also occurs automatically when the object has no physics forces to keep it awake, and when it is no longer moving a noticeable amount.
Wake
If the object was told to sleep, tell it to start moving again.
DisableMotion
Tell the object to stop moving completely. No physics forces will re-enable motion, not even Wake.
EnableMotion
If the object's motion has been disabled entirely, tell it to resume movement as usual. This will also Wake the object, if it is Sleeping.
DisableFloating
If the object would normally float when in water, tell it not to float. There seems to be no way to re-enable floating behavior, but programming a method to do this should be fairly simple (CALLBACK_DO_FLUID_SIMULATION).

BreakableProp:

Break
Breaks the breakable.
SetHealth <integer>
Sets a new value for the breakable's health. If the breakable's health reaches zero it will break.
AddHealth <integer>
Adds health to the breakable.
RemoveHealth <integer>
Removes health from the breakable.
physdamagescale <float>
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  (in all games since Half-Life 2: Episode One)
Allow this prop from playing its Punt Sound sound when punted by the gravity gun.
DisablePuntSound  (in all games since Half-Life 2: Episode One)
Prevent this prop from playing its Punt Sound sound when punted by the gravity gun.

Outputs

OnMotionEnabled
Fired when motion has been enabled on the prop, either via the Health Level to Override Motion keyvalue or from the EnableMotion input.
OnAwakened
Fired when the prop has woken (force has been applied to it while it was asleep, or the Wake input has been called).
OnOutOfWorld
Fired whenever the object is detected to be outside the world. Specifically, it checks if the object is outside of the world's bounding box or if the object is traveling at over 2000 units per second in any cardinal direction.
OnPlayerUse
Fired when the player has +used the prop.
Icon-Bug.pngBug*:!activator, as well as !caller are the physics prop itself!
Note.pngNote:This output (but not any of the other pickup-related ones) will fire only if the Generate output on +USE spawnflag is set.
OnPhysGunDrop
Fired when the player has dropped the prop (from either +use or the gravity gun). !activator is the player.
OnPlayerPickup
Fired when the player has picked the prop up with +use or the gravity gun (in Half-Life 2).
OnPhysGunOnlyPickup  (in all games since Half-Life 2)
Fired when the player has picked the prop up with the gravity gun specifically.
OnHitByTank  (in all games since Left 4 Dead 2)
Fired when the prop has been punched by a Tank boss infected.

BreakableProp:

OnBreak
Fired when this object breaks. !activator is whatever breaks the object.
OnHealthChanged <float>
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
Fired when damage is taken.
OnPhysCannonAnimatePreStarted
Fired when prop starts its ACT_PHYSCANNON_ANIMATE_PRE activity. Caused by the object being picked up by the gravity gun.
OnPhysCannonAnimatePullStarted
Fired when prop has started its ACT_PHYSCANNON_ANIMATE activity. ACT_PHYSCANNON_ANIMATE_PRE plays once, then ACT_PHYSCANNON_ANIMATE starts looping.
OnPhysCannonDetach
Fired when prop has started its ACT_PHYSCANNON_DETACH activity (caused by the gravity gun ripping it from a wall).
OnPhysCannonAnimatePostStarted
Fired when prop has started its ACT_PHYSCANNON_ANIMATE_POST activity (caused by the player letting the prop go from the gravity gun).
OnPhysCannonPullAnimFinished
Fired when prop has finished all gravity gun-related animations.

See also