getElementVelocity | Multi Theft Auto: Wiki Skip to content

getElementVelocity

Client-side
Server-side
Shared

Pair: setElementVelocity

This function returns three floats containing the velocity (movement speeds) along the X, Y, and Z axis respectively. This means that velocity values can be positive and negative for each axis. Supported element types are player, ped, vehicle, object, weapon, projectile and sound.

Note

OOP Syntax Help! I don't understand this!

  • Method:element:getVelocity(...)
  • Variable: .velocity

Syntax

float|false, ​float, ​float getElementVelocity ( ​element theElement )
Required Arguments
  • theElement: The element you wish to retrieve the velocity of.

Returns

  • float|false: vx
  • float: vy
  • float: vz

If succesful, returns three floats that represent the element's current velocity along the x, y and z axis respectively. This function will fail if the element specified does not have a velocity, or does not exist. In case of failure, the first return value will be false.

Code Examples

shared
OOP Required
local veh = Vehicle(411, 0, 0, 50)
local vel = veh.velocity
print(vel.x, vel.y, vel.z)

See Also

Element Functions