Animator.StopPlayback() Woes

I am new to all of this so it may be a simple answer :slight_smile: I am trying to make an animation stop playing when the player hits a wall… The animator is on the child of the GO. The collision is working, but the animation (and there is only one) is not stopping. What am i missing here?

the part that is not working is - animator.StopPlayback();

void Start()
{
     animator = GetComponentInChildren<Animator>();
}

void OnTriggerEnter2D(Collider2D other)
	{
		
		if (other.tag == "Wall")
		{
			
			rigidbody2D.velocity = Vector2.zero;
			animator.StopPlayback();
			
		}
	}

thanks,
ken

The issue is that StopPlayback does not stop the animation this is what it does: Stops the animator playback mode. When playback stops, the avatar resumes getting control from game logic. That is directly from the scripting reference.

The best way to do stop the animation IMO is to add a speed parameter to the animation and use animator.SetFloat(speed, 0) when the player hits a wall. Hope this helps for more information: Animator - Scripting Reference