How to rotate an entity

A game character can be rotated To a fixed orientation, or it can be rotated By a certain angle amount.

For example, imagine an entity's initial orientation is 25 degrees about the y-axis.

The entity can rotate To an orientation of 60 degrees about the y-axis, as shown below:

Or it can change its orientation By 60 degree about the y-axis. Doing so will rotate the entity 85 degrees about the y-axis, as shown below:

Rotate To an Orientation

To rotate an entity to an orientation of 45 degrees about the y-axis, you use the method U4DEngine::U4DEntity::rotateTo(), as shown below:

//Line 5. Rotate the character 45 degress about the y-axis
myAstronaut->rotateTo(0.0, 45.0, 0.0);

Rotate By an Amount

To rotate an entiy by an amount of 1.0 degrees about the y-axis, you use the method U4DEngine::U4DEntity::rotateBy(), as shown below:

//Line 6. Rotate the character by 1.0 degree about the y-axis
myAstronaut->rotateBy(0.0, 1.0, 0.0);

Last updated