Reference a RotationConstraint component

I need to reference the RotationConstraint. But I keep getting this error.

The type or namespace name ‘RotationConstraint’ could not be found (are you missing a using directive or an assembly reference?)

Here it is my piece of code in the object:

    public RotationConstraint rotationConstraint;

    void Start(){
     
        rotationConstraint = GetComponent<RotationConstraint>();

    }

Can someone explain to me what I’m missing?

Here’s the docs, you can see it’s in the UnityEngine.Animations namespace. Unless you’ve adding a Unity for that namespace, you’ll need to explicitly state it as it says “are you missing a using directive”.

1 Like