how do i get the animation to reset once the player moves

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PopSquip

I am trying to make realistic animations and I cant seem to get the animation to reset after the player steps off the grass.

    extends Area2D

func _physics_process(delta):
	var bodies = get_overlapping_bodies()
	for body in bodies:
		if == "Player":

how should i fix this?

:bust_in_silhouette: Reply From: Inces

You iterate thru total collision count. You made it so when player is colliding with the grass it plays STEPPED, but when players is not colliding - nothing happens, because there is no collision at all. Your NORMAL animation only plays when something other than player collides with it.
Another problem You have is that You force to play animation every frame. That means that as long as there is collision those animations reset every frame, never getting to end of animation loop.

I would use signals to solve this problem. On area enetered signal will make STEPPED play, on area exited - NORMAL. You can loop animations You want to repeat, or control loop using animation_ended signal