Null reference exception on animator

I call this method from other object and it’s null reference exception.

    public void Move()
    {
            Debug.Log(_animator.name);
            _animator.SetBool("Move", true);
    }
    void Start()
    {
        _animator = GetComponent<Animator>();
    }

it works fine when I assign animator in spawn function.Also debug in update shows that _animator exists.What can it be?

Good day.

Maybe you having “timing” problems. ASs you say, the method Move is called from another object, but is called at same time as the object is created?

You should check if “start” is called before “Move”. Use some Debug.Log in each method to see what is called first.

Maybe wou need to do

 _animator = GetComponent<Animator>();

inside “move” to ve sure its executed before the other commands.

Salute!

Thanks, that was the problem exactly, had to use awake instead of start;