PhysicsApplyVelocity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} Applies velocity to rigid body ==Syntax== <syntaxhighlight lang="lua"> bool ohysicsApplyVelocity( physics-rigid-body theRigidBody, float veloc...")
 
No edit summary
 
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool ohysicsApplyVelocity( physics-rigid-body theRigidBody, float velocityX, float velocityY, float velocityZ [, float relativeX, float relativeY, float relativeZ ] )             
bool physicsApplyVelocity( physics-rigid-body theRigidBody, float velocityX, float velocityY, float velocityZ [, float relativeX, float relativeY, float relativeZ ] )             
</syntaxhighlight>  
</syntaxhighlight>  



Latest revision as of 11:33, 14 February 2020

Applies velocity to rigid body

Syntax

bool physicsApplyVelocity( physics-rigid-body theRigidBody, float velocityX, float velocityY, float velocityZ [, float relativeX, float relativeY, float relativeZ ] )             

Required Arguments

  • theRigidBody: rigid body you want to apply velocity
  • velocityXYZ: velocity you wants to apply
  • relativeXYZ: relative position, default: 0,0,0

Returns

True if velocity got applied, false otherwise.

Example

Doing box flip

local box = physicsCreateShape(physics, "box", 1)
local function spawnTestBox(x,y,z)
  local boxrb = physicsCreateRigidBody(box)
  physicsSetProperties(boxrb, "position", x,y,z)
  return boxrb;
end

local notATable = spawnTestBox(0,0,5)
setTimer(function()
  physicsApplyVelocity(notATable , 0,0,10, 0,1,0)
end,500,1) -- let box land on the ground.

See Also