Gravity: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎QPhysics: not global at all, useless outside that .cpp file)
No edit summary
Line 8: Line 8:
: Sets the direction and strength of gravity for the VPhysics environment, which can be changed at any time independently of sv_gravity. 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. {{tip|Z should be ''negative'' for downward pull.}} {{note|Changes must be manually networked to the client.}}  
: Sets the direction and strength of gravity for the VPhysics environment, which can be changed at any time independently of sv_gravity. 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. {{tip|Z should be ''negative'' for downward pull.}} {{note|Changes must be manually networked to the client.}}  
; <code>void [[IPhysicsObject]]::EnableGravity([[bool]] enable)</code>
; <code>void [[IPhysicsObject]]::EnableGravity([[bool]] enable)</code>
: Zero gravity. The object will tumble through the air if pushed.
: Controls per-entity zero gravity. The object will tumble through the air if pushed.
: {{todo|Is there a way to set a gravity multiplier?}}
: {{todo|Is there a way to set a gravity multiplier?}}


Line 14: Line 14:


; <code>void CBaseEntity::PhysicsAddGravityMove([[Vector]] &move)</code>
; <code>void CBaseEntity::PhysicsAddGravityMove([[Vector]] &move)</code>
: Use <code>sv_gravity</code> to add gravity to QPhysics entities ({{todo|including NPCs?}}).
: Uses <code>sv_gravity</code> to add gravity to falling QPhysics entities ({{todo|including NPCs?}}).
; <code>void CGameMovement::AddGravity()</code>
; <code>void CGameMovement::AddGravity()</code>
: As above, but for players.
: As above, but for players.

Revision as of 12:14, 15 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 independently of sv_gravity. 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.
Tip.pngTip:Z should be negative for downward pull.
Note.pngNote:Changes must be manually networked to the client.
void IPhysicsObject::EnableGravity(bool enable)
Controls per-entity zero gravity. The object will tumble through the air if pushed.
Todo: Is there a way to set a gravity multiplier?

QPhysics

void CBaseEntity::PhysicsAddGravityMove(Vector &move)
Uses sv_gravity to add gravity to falling 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.pngTip: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.

See also