Ghadim Alehsan
Ghadim Alehsan

Reputation: 43

How Reset Unity Animator And Animation Clip?

I'm working on 2D game in unity and the game has several animation clip like : Idle, Idle Stomach, Figure and etc. Also I have two section in my scene: 1- home 2-character

My default animation is "Idle" and I use SetTrigger to run the specific animation clip. Animation and trigger work fine but when I trigger from "Idle" to another animation like "Figure" and switch between home and character (character section false -> home section true -> home section false, character section true) , my Idle animation blend with another clip witch it has trigger before and it has some frame from figure or stomach animation.

enter image description here

How can I reset animator like when scene load? or reset Idle clip for example?

I try these separately :

  1. true/false animator component
  2. set trigger Idle animation again
  3. use Play("normalState", 0, 0f);

but didn't work.

Upvotes: 3

Views: 1885

Answers (1)

prestoneccles
prestoneccles

Reputation: 1

You could try the exit node in the animator, doing this will automatically make the animator go the default animation clip.

https://i.sstatic.net/XigM7.png

Add this to layer 0 and use Play("Exit", 0);

Upvotes: 0

Related Questions