static Rotation SmoothDamp( Rotation current, Rotation& target, Vector3& velocity, float smoothTime, float deltaTime )

robot_2Generated
code_blocksInput

Description

The Rotation.SmoothDamp method is a static function that smoothly interpolates between two rotations over time. It is particularly useful for creating smooth transitions in animations or camera movements. The method uses a damping function to gradually change the current rotation towards the target rotation, taking into account the current velocity and the desired smooth time.

Usage

To use the Rotation.SmoothDamp method, provide the current rotation, the target rotation, a reference to the current velocity, the smooth time, and the delta time. The method will return the new rotation that is closer to the target rotation.

The velocity parameter is updated by the method to reflect the current velocity of the rotation change, which can be reused in subsequent calls to maintain smoothness.

Example

// Example usage of Rotation.SmoothDamp
Rotation currentRotation = Rotation.Identity;
Rotation targetRotation = Rotation.FromAxis(Vector3.Up, 90);
Vector3 velocity = Vector3.Zero;
float smoothTime = 0.3f;
float deltaTime = Time.Delta;

Rotation newRotation = Rotation.SmoothDamp(currentRotation, ref targetRotation, ref velocity, smoothTime, deltaTime);

// Apply the new rotation to an object
myGameObject.Rotation = newRotation;