Change the direction and speed of an entity while flying during runtime

From SIMboxWiki
Revision as of 20:07, 11 March 2010 by Seanjarvis (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can change the object position during runtime by calling the following action:


ACTION_START_MODEL_MOTION (Location newLocation, LinearVec newSpeed)

The newLocation is the object required 6Dof state.
The newSpeed is the object required speed in world coordinates.


To set the new entity in world coordinates X = 1000, Y = 2000, Z = 0, and Yaw = 20degs, with a speed of 200m/sec, use:

LinearVec newPos(1000, 2000, 0);
AngularVec newOri(Ang::zero(),Ang::zero(),Ang(Deg(20.0)));
LinearVec newSpeed(200*sinf(20.0f * RADTODEG), 200*cosf(20.0f * RADTODEG) , 0);
CALL_ENTITY_ACTION_2(_pOwnerEntity, EntityWorld::ACTION_START_MODEL_MOTION, Location(newPos,newOri),newSpeed);