format
typescript
Vector3.RotateTowards(source, target, max_delta_radians, max_delta_mag)class: Vector3
description
Rotates a game object from its current direction to a target direction.
The direction is similar to MoveTowards, but instead of representing the position of the object, it represents the direction. The game object will rotate from the source direction to the target direction. This method is useful for smoothly rotating between two vectors, commonly used for controlling the rotation direction of an object or achieving smooth turning effects.
parameter
| param_name | type | description |
|---|---|---|
| source | Vector3 | The current direction. |
| target | Vector3 | The target direction. |
| max_delta_radians | number | The maximum number of radians the current vector can rotate. |
| max_delta_mag | number | The maximum size the current vector can scale. |
return
| type | description |
|---|---|
Vector3 | The rotated angle after the rotation. |
code example
typescript
let lhs = new Vector3(1,2,3);
let rhs = new Vector3(3,4,5);
let v3_result = Vector3.RotateTowards(lhs, rhs, 90, 1);
Debug.Log("add result is",v3_result);