How to translate an entity

Translating a 3D Object

The Untold Engine provides two ways to translate a game object. The engine can translate an object to an absolute position. Or it can translate the object by a specified amount.

For example, imagine the original position of the object is (3,0,0). If you want to move the object to location (5,0,0), you inform the engine to move the entity To position (5,0,0).

However, if you move the entity By an amount of (5,0,0), the engine will move the object to position (8,0,0).

1. Translate To Location

To translate an entity to a location, you use the method U4DEngine::U4DEntity::translateTo().

For example, the snippet below shows how to translate the character to location (-2.0,1.0,2.0).

//Line 5. Translate the game object to location (-2.0, 1.0, 2.0)
myAstronaut->translateTo(-2.0, 1.0, 2.0);

2. Translate By an amount

To translate an entity by a particular amount, you use the method U4DEngine::U4DEntity::translateBy().

For example, the snippet below translates the character by 5.0 units along the +x-axis;

//Line 6. Translate the game object BY an amount of 5.0 units along the x-axis
myAstronaut->translateBy(5.0, 0.0, 0.0);

Last updated