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

From SIMboxWiki
Revision as of 15:21, 11 March 2010 by Orenfr (talk | contribs)
Jump to navigation Jump to search

The way to change the object position is 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);