Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Thore on September 12, 2017, 04:26:34 PM

Title: FSM ↔ Mechanim (Set Animation Trigger behaves like bool)
Post by: Thore on September 12, 2017, 04:26:34 PM
Ahoy,

TL;DR: I send a Set Animation Trigger to mechanim, but instead of sending only an impulse, the triggers appear to be on or off, behaving like bools. I ruled out that I accidentally set them every frame.   

Q1: You see the triggers are filled or "on". They were triggered once (correctly) after spawning, because the character drops down shortly. The states that send the anim trigger are passed through only, and marked with the exclamation marks. There are none on Ground.

Q2: Why keeps velocity fluctuating as you see in the screenshot despite that the character is completely at rest? (it seems to have no effect on gameplay, though)

EDIT: I found out that triggers work like bools, but are supposed to be reset when the animation clip transitioned. Someone over at Unity wrote this:

Quote from: User (http://answers.unity3d.com/questions/981044/animator-trigger-not-reseting-bug.html)
... Use triggers only if you are sure the animation will play full, from begginig to end, before issuing another trigger...
Title: Re: FSM ↔ Mechanim (Set Animation Trigger behaves like bool)
Post by: jeanfabre on September 15, 2017, 04:19:20 AM
Hi,

 I am not sure about the outcome, is it working now? or at least do you know understand how trigger works? or do you still have an issue with this?

 Bye,

 Jean
Title: Re: FSM ↔ Mechanim (Set Animation Trigger behaves like bool)
Post by: Thore on September 15, 2017, 05:35:22 AM
I have no idea what was wrong and am none the smarter. I now changed the setup around.

I wanted to use the trigger because I didn't want to constantly update velocity floats for the mechanim. It occured to me that I don't need to do that anyway. Instead of triggering, I set the float at desired times to (somewhat arbitrary) values and use that to move the animations to the desired state. In other words, the value might change constantly in the FSM, but the Mechanim can have it simpler and only needs to know once that velocity is, say above 5, to move into the correct animation.

In case someone wants to know how: when your character is jumping, set the animator float to, say "5" and then in mechanim the condition so that if value is greater than 4 to move into the desired animation. Simply space out the values to make jumping (trigger), rising (velocity is above 0.3), falling (below 0) and landing (above 0, but following the falling state).