Answers for "how to rotate towards a certain rotation unity"

C#
4

unity rotate towards

Quaternion.RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta);
Posted by: Guest on March-07-2020
-1

unity rotate towards

public Transform target; 
public float rotSpeed;  

void Update()
{  
    // erase any position difference in the Z axis
    // direction will be a flat vector in the global XY plane without depth information
    Vector2 targetDirection = target.position - transform.position;

    // Now use Lerp as you did
    transform.right = Vector3.Lerp(transform.right, targetDirection, rotationSpeed * Time.deltaTime);
}
Posted by: Guest on March-26-2022

Code answers related to "how to rotate towards a certain rotation unity"

C# Answers by Framework

Browse Popular Code Answers by Language