Velocity: Difference between revisions
Jump to navigation
Jump to search
Warning:Don't try to change another entity's local or absolute velocity, as it will likely overwrite both values when it next tries to move. Instead, add to the existing base value with
TomEdwards (talk | contribs) (Created page with ''''Velocity''' is a measure of speed and direction. In Source, it is a <code>Vector</code> that an entity will try to move the length of once per second: a velocity of <code>…') |
TomEdwards (talk | contribs) No edit summary |
||
Line 11: | Line 11: | ||
Having separate local and base velocities allows for the proper handling of [[Wikipedia:Inertia|inertia]]. If an NPC is standing on a fast-moving train, the motion of the carriage is stored in its base velocity while the motion the NPC creates itself when walking up and down is stored in its local velocity. There is no danger of either value overwriting the other, or of the NPC thinking it's walking at 150MPH. | Having separate local and base velocities allows for the proper handling of [[Wikipedia:Inertia|inertia]]. If an NPC is standing on a fast-moving train, the motion of the carriage is stored in its base velocity while the motion the NPC creates itself when walking up and down is stored in its local velocity. There is no danger of either value overwriting the other, or of the NPC thinking it's walking at 150MPH. | ||
{{warning|Don't try to change another entity's local or absolute velocity | {{warning|Don't try to change another entity's local or absolute velocity, as it will likely overwrite both values when it next tries to move. Instead, add to the existing base value with <code>SetBaseVelocity()</code>. }} | ||
== Functions == | == Functions == |
Revision as of 11:38, 26 June 2009
Velocity is a measure of speed and direction. In Source, it is a Vector
that an entity will try to move the length of once per second: a velocity of (0,0,-200)
means that you are falling at 200 units per second.
Abs, local and base
There are actually three different velocity vectors:
- Local velocity: generated by the entity
- Base velocity: applied to the entity from other sources
- Absolute velocity: the sum of the local and base velocities; the actual value used to move
Having separate local and base velocities allows for the proper handling of inertia. If an NPC is standing on a fast-moving train, the motion of the carriage is stored in its base velocity while the motion the NPC creates itself when walking up and down is stored in its local velocity. There is no danger of either value overwriting the other, or of the NPC thinking it's walking at 150MPH.

SetBaseVelocity()
. Functions
GetLocalVelocity()
,SetLocalVelocity()
GetBaseVelocity()
,SetBaseVelocity()
GetAbsVelocity()
,SetAbsVelocity()