Difference between revisions of "Change the direction and speed of an entity while flying during runtime"

From SIMboxWiki
Jump to navigation Jump to search
(New page: 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 6D...)
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
The way to change the object position is by calling the following action:
+
You can change the object position during runtime by calling the following action:
  
  
 
ACTION_START_MODEL_MOTION (Location newLocation, LinearVec newSpeed)
 
ACTION_START_MODEL_MOTION (Location newLocation, LinearVec newSpeed)
  
 +
:The newLocation is the object required 6Dof state.
  
The newLocation is the object required 6Dof state.
+
:The newSpeed is the object required speed in world coordinates.
  
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:
  
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);
  
                LinearVec newPos(1000, 2000, 0);
+
:AngularVec newOri(Ang::zero(),Ang::zero(),Ang(Deg(20.0)));
  
                AngularVec newOri(Ang::zero(),Ang::zero(),Ang(Deg(20.0)));
+
:LinearVec newSpeed(200*sinf(20.0f * RADTODEG), 200*cosf(20.0f * RADTODEG) , 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);
  
                CALL_ENTITY_ACTION_2(_pOwnerEntity, EntityWorld::ACTION_START_MODEL_MOTION, Location(newPos,newOri),newSpeed);
+
[[Category:Development Articles]][[Category:Motion Models]]

Latest revision as of 20:07, 11 March 2010

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);