Object tries to rotate to another object degree...

Hola a todos!

We’re working on a simple game, with some cute mexican characters…but we got stuck on something that is probably very simple for a coder, but not for us ( us dumb artist :shock: )

We just would like to get this simple behavior: we rotate an object, and another object continuously tries to follow and get to the same degree of rotation, with a given speed/lag.

We’re not using any character control or anything, it’s just a behavior between two generic objects.

Muchas gracias a todos, thanks for your help!!

Hello there!

I’m not 100% certain on what it is you want.
Do you want your second object to move in position aswell or only adjust it’s rotation?
Do you want this script to run in the editor or when the application is running?

If it’s not position change and done while the application is running the following script should do the trick:

public class FollowRotation : MonoBehaviour
{
    public Transform mTarget;
    public float mRotationSpeed;
   
    void Update()
    {
        transform.rotation =
            Quaternion.RotateTowards(transform.rotation, mTarget.rotation, mRotationSpeed * Time.deltaTime);
    }
}

Put that script on the object you want to adjust rotation on and put the one you want to mimic as Target.
The rotation speed is given in degrees/second.

Myx, may the almighty Gods of Metal bless you up there in the forests of Sweden!! It definitely works!

That might be the most enthusiastic “thank you” I have ever recieved!
Glad that I could be of assistance!

Hello Myx, I sent you a PM!