Gravity: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎QPhysics: not global at all, useless outside that .cpp file)
Line 19: Line 19:
;<code>void CBaseEntity::SetGravity([[float]] gravity)</code>
;<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.}}
: 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( CBaseEntity* pEnt )</code>
: Global helper that returns (world gravity) * (entity gravity).


== See also ==
== See also ==

Revision as of 09:28, 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)
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)
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.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