Gravity: Difference between revisions
Jump to navigation
Jump to search
TomEdwards (talk | contribs) mNo edit summary |
TomEdwards (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
'''Gravity''' in Source is measured in [[unit]]s/second<sup>2</sup>. The value is defined by '''<code>sv_gravity</code>''', which defaults to 600 in Half-Life 2 (and episodes) and 800 in Valve's other games. | '''Gravity''' in Source is measured in [[unit]]s/second<sup>2</sup>. The value is defined by '''<code>sv_gravity</code>''', which defaults to 600 in Half-Life 2 (and episodes) and 800 in Valve's other games. | ||
== C++ == | == C++ functions == | ||
=== [[VPhysics]] === | |||
; <code>void [[physenv]]->SetGravity([[Vector]] &gravityVector)</code> | |||
: Sets the direction and strength of gravity for the VPhysics environment, which can be changed at any time. Physics objects will sleep on the 'floor' no matter which direction it is in, but they will ''not'' wake of their own accord if gravity changes. (<code>physenv</code> is global) {{tip|Z should be ''negative'' for downward pull.}} {{note|Changes must be manually networked to the client.}} | |||
:{{todo|Is there a way to set gravity on individual objects?}} | |||
; <code>void [[IPhysicsObject]]::EnableGravity([[bool]] enable)</code> | |||
: Zero gravity. The object will tumble through the air if pushed. | |||
=== [[QPhysics]] === | |||
; <code>void CBaseEntity::PhysicsAddGravityMove([[Vector]] &move)</code> | |||
: Use <code>sv_gravity</code> to add gravity to QPhysics entities ({{todo|including NPCs?}}). | |||
; <code>void CGameMovement::AddGravity()</code> | |||
: As above, but for players. | |||
;<code>void CBaseEntity::SetGravity([[float]] gravity)</code> | |||
: Sets a per-entity multiplier for QPhysics gravity. Default is 0, which should be considered 1. {{tip|The Hammer keyvalue ''gravity'' can be used to add a gravity multiplier to individual QPhysics entities (which more or less means NPCs these days) without any new code. It isn't in the [[FGD]] so turn off SmartEdit and add it manually.}} | |||
; <code>float GetActualGravity()</code> | |||
: Helper that returns (world gravity) * (entity gravity). | |||
== See also == | |||
* [[trigger_gravity]] | |||
[[Category:Glossary]] | [[Category:Glossary]] | ||
[[Category:Programming]] | [[Category:Programming]] |
Revision as of 15:45, 12 June 2009
Gravity in Source is measured in units/second2. The value is defined by sv_gravity
, which defaults to 600 in Half-Life 2 (and episodes) and 800 in Valve's other games.
C++ functions
VPhysics
void physenv->SetGravity(Vector &gravityVector)
- Sets the direction and strength of gravity for the VPhysics environment, which can be changed at any time. Physics objects will sleep on the 'floor' no matter which direction it is in, but they will not wake of their own accord if gravity changes. (
physenv
is global)Tip:Z should be negative for downward pull.
Note:Changes must be manually networked to the client.
- Todo: Is there a way to set gravity on individual objects?
void IPhysicsObject::EnableGravity(bool enable)
- Zero gravity. The object will tumble through the air if pushed.
QPhysics
void CBaseEntity::PhysicsAddGravityMove(Vector &move)
- Use
sv_gravity
to add gravity to QPhysics entities (Todo: including NPCs?). void CGameMovement::AddGravity()
- As above, but for players.
void CBaseEntity::SetGravity(float gravity)
- Sets a per-entity multiplier for QPhysics gravity. Default is 0, which should be considered 1.
Tip:The Hammer keyvalue gravity can be used to add a gravity multiplier to individual QPhysics entities (which more or less means NPCs these days) without any new code. It isn't in the FGD so turn off SmartEdit and add it manually.
float GetActualGravity()
- Helper that returns (world gravity) * (entity gravity).