Trying to change an animation with a UI button

I’m a total noob at Unity and don’t know c#, so the struggle is real. All i’m trying to do is change my main character’s idle animated state to its happy animated state with a UI button click. What code do I need for that? 83306-screen-shot-2016-12-03-at-11628-pm.png

Good news! You don’t need code :wink:

1 : Add a Trigger parameter to your Animator Controller

2 : Add a Transition Condition using the Trigger

83311-screen-shot-2016-12-03-at-211922.png

3 : On the UI Button object, add an OnClick event, drag the object with the Animator component in the field on the left, on the right, select Animator>Set Trigger (string), then give it the name of the trigger parameter.

I would use code, but for a quick prototype, that works.

Oh my lord… it actually worked!! @jikkou Is there any way to have the trigger interrupt the animation? I notice that it waits for the first animation to finish before switching. Can it immediately switch once the button is clicked?