R3d.Body:applyLocalTorque: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:


=== Description ===
=== Description ===
Applies a torque to the body.
Applies a torque to the body in local-space.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
r3d.Body:applyLocalTorque(torqueX,torqueY,torqueZ)
r3d.Body:applyLocalTorque(torqueX,torqueY,torqueZ)
Line 10: Line 10:
The specified force/torque will be added to the total force/torque applied to the rigid body.
The specified force/torque will be added to the total force/torque applied to the rigid body.


At the end of each call to the PhysicsWorld::update(), the total force/torque of all the rigid bodies will be reset to zero. You need to call ''applyLocalTorque'' during several frames if you want the force/torque to be applied during a certain amount of time.
At the end of each call to the ''PhysicsWorld::update()'', the total force/torque of all the rigid bodies will be reset to zero. You need to call ''applyLocalTorque'' during several frames if you want the force/torque to be applied during a certain amount of time.


=== Parameters ===
=== Parameters ===
Line 19: Line 19:
=== Example ===
=== Example ===
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
if isleft then ship.body:applyLocalTorque(0, -24 * 64, 0) end
if isleft then ship.body:applyLocalTorque(0, -24*64, 0) end
</syntaxhighlight>
</syntaxhighlight>


{{R3d.Body}}
{{R3d.Body}}

Latest revision as of 10:21, 18 December 2025

Available since: Gideros 2019.10
Class: R3d.Body

Description

Applies a torque to the body in local-space.

r3d.Body:applyLocalTorque(torqueX,torqueY,torqueZ)

The specified force/torque will be added to the total force/torque applied to the rigid body.

At the end of each call to the PhysicsWorld::update(), the total force/torque of all the rigid bodies will be reset to zero. You need to call applyLocalTorque during several frames if you want the force/torque to be applied during a certain amount of time.

Parameters

torqueX: (number) applies a torque in Newton meters on the X axis
torqueY: (number) applies a torque in Newton meters on the Y axis
torqueZ: (number) applies a torque in Newton meters on the Z axis

Example

if isleft then ship.body:applyLocalTorque(0, -24*64, 0) end