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 particular direction in 3D space.
Usage
To use the LookAt
method, provide two Vector3
parameters:
forward
: The direction you want the object to face.
up
: The up direction to use for orientation.
The method returns a Rotation
that can be applied to an object to make it face the specified direction.
Example
// Example usage of Rotation.LookAt
Vector3 targetDirection = new Vector3(1, 0, 0); // Target direction
Vector3 upDirection = new Vector3(0, 1, 0); // Up direction
Rotation rotation = Rotation.LookAt(targetDirection, upDirection);
// Apply the rotation to a game object
GameObject myObject = new GameObject();
myObject.Transform.Rotation = rotation;