Description
The Rotation.LookAt
method creates a Rotation
that aligns the forward direction with a specified target direction, using an additional up vector to determine the orientation around the forward axis. This is useful for orienting objects to face a specific direction in 3D space.
Usage
To use the LookAt
method, provide two Vector3
parameters: forward
and up
. The forward
vector specifies the direction to look towards, while the up
vector defines the upward direction relative to the object, ensuring the rotation is correctly oriented.
Example
// Example of using Rotation.LookAt
Vector3 targetDirection = new Vector3(1, 0, 0); // Target direction to look at
Vector3 upDirection = new Vector3(0, 1, 0); // Up direction
Rotation rotation = Rotation.LookAt(targetDirection, upDirection);
// Apply the rotation to an object
GameObject myObject = new GameObject();
myObject.Transform.Rotation = rotation;