Prop physics
From Valve Developer Community
This point-based entity is available in all Source games.
| Table of contents |
Entity Description
An entity which, when placed in a map and set with a model, creates a prop which is influenced by the engine physics, meaning they can fully interact with their world in terms of collision, gravity, constraints, and world effects. If you have played a Source game in any form you have definitely seen one in action. (These were the objects you could move or pick up, by hand or by using the grav gun, according to their weight.)
Additional settings in the entity include a multiplier for weight, name field for I/O interactions, damage type (sharp or blunt), etc. Entities can be flagged to start motion disabled (think saw-blades), allow or disallow gravity gun pickup, be configured to break when it takes enough damage, etc.
Alternative entities
If you are creating a multiplayer map, you should instead use a prop_physics_multiplayer for most objects instead of a prop_physics. Prop_physics is ideal for single-player maps, where accuracy of interactions has no network overhead to worry about. The detail going into the interaction between objects in multiplayer results in an undesirably large network overhead and thus requires the detail of the interactive aspects of the objects be simplified. To solve this, Valve created prop_physics_multiplayer, which uses a much simpler structure of the model to do physics interactions, resulting in much better network play. Extremely simple models (simple being anything "boxy" [computer cases, keyboards, small jars, etc.]) will not have prop_physics_multiplayer settings, but this is fine because those models are so simple that making them prop_physics will not have an adverse effect on network traffic. If you are having a problem in a multiplayer map with a small object that is behaving strangely as a prop_physics_multiplayer, try making it a prop_physics.
If you are mapping for Half-Life 2: Deathmatch and want your breakable objects to come back after a while, use a prop_physics_respawnable instead.
Consistency
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. To enforce this, the game-related data of props is stored within the model itself. 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. 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.
See also
- prop_physics_multiplayer
- prop_physics_override
- prop_physics_respawnable
- Prop Data
- Prop Types Overview - Description of the various model prop entities.
- Prop Footsteps - A tutorial that provides essential code for when players walk on entities like this, it's not ignored during footstep sound computation.
Keyvalues
- targetname <target_source>
- Defines the name that other entities refer to this entity by.
- hammerid [Episode Two Update]
- <integer readonly> This id is used for debugging purposes in Hammer.
- Pitch Yaw Roll (Y Z X)
- This entity's angular orientation in the world (also used for angular effect entities).
- globalname
- <string> Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.
- model
- <studio> World Model (Maximum string length: 128)
- skin
- <integer> Some models have multiple versions of their textures called skins. Set this to a number other than 0 to use that skin instead of the default.
- disableshadows
- <boolean> Used to disable dynamic shadow casting from this entity.
- damagefilter <target_destination>
- Name of the filter_damage_type entity that controls which entities can damage us.
- 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'.
- 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'.
- PerformanceMode <choices>
- Used to limit the amount of gibs produced when this entity breaks, for performance reasons.
Literal Value Description 0 Normal 1 Limit Gibs 2 Full Gibs on All Platforms
- pressuredelay <float>
- Delay, in seconds, after 'broken' by pressure before breaking apart (allows for sound to play before breaking apart).
- mindxlevel
- <choices> Minimum DX Level
Literal Value Description 0 default (lowest) 70 dx7
- maxdxlevel
- <choices> Maximum DX Level
Literal Value Description 0 default (lowest) 60 dx6
- minhealthdmg
- <integer> The prop will ignore any damage events if the damage is less than this amount.
- shadowcastdist
- <integer> Use this to override how far this object casts shadows. 0 = default distance.
- physdamagescale
- <float> Scales damage energy when this object is hit by a physics object.
- Set to 1.0 for materials as strong as flesh, smaller numbers indicate stronger materials.
- Damagetype
- <boolean> If set, damage type is sharp, otherwise blunt.
- nodamageforces
- <boolean> Used to determine whether or not damage should cause the brush to move.
- inertiaScale
- <float> Scales the angular mass of an object. Used to hack angular damage and collision response.
- massScale
- <float> A scale multiplier for the object's mass.
- overridescript
- <string> A list of physics key/value pairs that are usually in a physics prop .qc file. Format is 'key,value,key,value,etc'.
- damagetoenablemotion
- <integer> If specified, this object will start motion disabled. Once its health has dropped below this specified amount, it will enable motion.
- forcetoenablemotion
- <float>If specified, this object will start motion disabled. Any impact that imparts a force greater than this value on the physbox will enable motion.
- fademindist
- <float> Start Fade Dist/Pixels - Distance at which the prop starts to fade. (-1 = Use fademaxdist.)
Note: If this entity is in a 3D Skybox, this value will automatically be scaled properly.
- fademaxdist
- <float> End Fade Dist/Pixels - Max fade distance at which the prop is visible. (0 = Don't fade out.)
Note: If this entity is in a 3D Skybox, this value will automatically be scaled properly.
- fadescale
- <float> Fade Scale - If you specify a fade in the worldspawn, or if the engine is running under dx7, the engine will forcibly fade out props even if fademindist/fademaxdist isn't specified. This scale factor gives you some control over the fade. Using 0 here turns off the forcible fades. Numbers smaller than 1 cause the prop to fade out at further distances, and greater than 1 cause it to fade out at closer distances.
- puntsound [Episode One Update]
- <sound> Sound to make when punted
Flags
- 1 : Start Asleep
- 2 : Don't take physics damage
- 4 : Debris - Don't collide with the player or other debris
- 8 : Motion Disabled
- 16 : Break on Touch
- 32 : Break on Pressure
- 64 : Enable motion on Physcannon grab
- 128 : Not affected by rotor wash
- 256 : Generate output on +USE
- 512 : Prevent pickup
- 1024 : Prevent motion enable on player bump
- 4096 : Debris with trigger interaction
- 8192 : Force server-side (Multiplayer only) [Episode One Update]
- If this object has to be server-side, set this flag. See sv_pushaway_clientside_size.
- 1048576 : Physgun can ALWAYS pick up. No matter what. [Episode One Update]
- Should force breakable models to have pieces break on the server?
Inputs
- Break
- Breaks the breakable completely. This will make the entity act like a normal func_breakable. If you wish to maintain the shattering behaviour/appearance, consider using the Shatter input below with a large radius value.
- 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. If the breakable's health reaches zero it will break.
- RemoveHealth <integer>
- Removes health from the breakable. If the breakable's health reaches zero it will break.
- EnablePhyscannonPickup
- Makes the breakable able to picked up by the physcannon.
- DisablePhyscannonPickup
- Makes the breakable not able to picked up by the physcannon.
- Ignite
- Ignite the target entity.
- SetDamageFilter <target_destination>
- Sets the entity to use as damage filter. Pass in an empty string to clear the damage filter.
- Kill
- Removes this entity from the world.
- Removes this entity and all its children from the world.
- AddOutput <string>
- Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
- Format:
<key> <value> - Format:
<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>
- Causes this entity's OnUser1-4 outputs to be fired. See User Inputs and Outputs.
- Skin <integer>
- Changes the model skin to the specified number.
- SetBodyGroup <integer>
- Set this prop's body group (from 0 - n). Changes the model body to the specified number.
- DisableShadow
- Turn shadow off.
- EnableShadow
- Turn shadow on.
- AlternativeSorting <bool> [Episode One Update]
- Used to attempt to fix sorting problems when rendering. True activates, false deactivates
- Wake
- Wake up this physics object, if it is sleeping.
- Sleep
- Put this physics object to sleep. It will wake if given the Wake input, or if force is applied to it. Note that physics objects go to sleep automatically after coming to rest for a while, so you don't really need to use this.
- EnableMotion
- Enable physics motion/collision response.
- DisableMotion
- Disable physics motion/collision response.
- DisableFloating
- Disable fluid/floating simulation to reduce cost.
- physdamagescale <float>
- Set the Physics Impact Damage Scale for this character.
- EnableDamageForces
- Damaging the entity applies physics forces to it.
- DisableDamageForces
- Damaging the entity does *not* apply physics forces to it.
- EnablePuntSound [Episode One Update]
- Allow this prop to play its own sound when punted
- DisablePuntSound [Episode One Update]
- Prevent this prop from playing its own sound when punted
- EnableDamageForces [Episode Two Update]
- DisableDamageForces [Episode Two Update]
Outputs
- OnBreak
- OnHealthChanged
- OnIgnite
- OnPhysCannonDetach
- OnUser1-4
- Fired in response to FireUser1-4 inputs. See User Inputs and Outputs.
- !activator = activator
- OnMotionEnabled
- Fired when motion is enabled on this prop, either via the Health Level to Override Motion keyvalue or from the EnableMotion input.
- OnAwakened
- Fired when this entity becomes awake (collision/force is applied to it while it's asleep).
- OnPhysGunPickup
- Fired when the player picks up the prop with the physcannon or +USE.
- !activator = player Deprecated [Episode One Update]
- OnPhysGunDrop
- Fired when the player drops the prop with the physcannon or +USE.
- !activator = player
- OnPlayerUse
- Fired when the player tries to +USE the physbox. This output will fire only if the Generate output on +USE spawnflag is set.
- !activator = player
- OnPhysGunOnlyPickup [Episode One Update]
- Fired when a player picks this object up WITH THE PHYSGUN. +USE pickups do not fire this output.
- OnPlayerPickup [Episode One Update]
- Fired whenever the player picks up this prop (with the physcannon or with +USE).
- OnOutOfWorld [Episode Two Update]
- OnHealthChanged [Episode Two Update]
- OnTakeDamage [Episode Two Update]
