Error Unit Animator not assigned, while it is assigned

Unity is complaining that I’m using my _unitAnimator variable while it is not assigned. However, it clearly is assigned in the editor:

    [SerializeField] private Animator _unitAnimator;

    private void Update()
    {
        _unitAnimator.SetBool("IsWalking", IsWalking()); // Complains here
        // Cut out irrelevant code
    }

    private bool IsWalking()
    {
        return transform.position != _targetPosition;
    }

The unit animator was set in the editor while not in play mode. :wink:
I tried restarting Unity and renaming the variable and reassigning it in the editor.
Any ideas what might be happening here?

Never mind: it turns out that I accidentally dragged a Unit script component onto the floor plane, which indeed did not have the animator reference assigned.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms