Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Fat Pug Studio on August 10, 2018, 08:51:43 AM

Title: Get Animator State Last Frame[Solved]
Post by: Fat Pug Studio on August 10, 2018, 08:51:43 AM
Hey guys, i'm rigging animations for my game, and i'm having some troubles with the Animator.

For every weapon switching in the game i've got an animation of old weapon going in the ship, and the animation for new weapon coming out of the ship. So that's two animations.

Of course, i don't want the player to be able to shoot when the weapon is pulling in/drawing out, so when the weapon goes in, animator goes into "idle" state, then i use Get Animator Current State Info i compare the state name every frame, and when it matches with "idle", i start the animation of weapon coming out.

The thing is, i can't use the "idle" logic on this one, since the animator needs to stay on the last frame of the animation (gun completely pulled out, no loop time animation) until the next weapon switch.

So, any ideas how to get the info on the moment the animation hits the last frame? Is it normalized time = 1?
Title: Re: Get Animator State Last Frame
Post by: GonerGames on August 10, 2018, 05:42:23 PM
You could have a animation state specific to this action with a "Changing Gun" Bool to prevent firing during this sequence.

IE. - Idle -> Bool true -> Changing gun state -> Trigger Weapon in -> Changing gun state -> Trigger Weapon out ->  Changing Gun state -> Bool to False->  Idle

This saves you from having to check animation states every frame.

If you want to do a small script to fire off events during the animation then you can use this https://docs.unity3d.com/Manual/animeditor-AnimationEvents.html (https://docs.unity3d.com/Manual/animeditor-AnimationEvents.html) for reference.
Title: Re: Get Animator State Last Frame
Post by: Fat Pug Studio on August 11, 2018, 11:28:02 AM
Thanks man. I'll try it out, tho checking if normalized time is 1 seems to do the trick. I also found is animation playing action, i'll try that out too.
Title: Re: Get Animator State Last Frame
Post by: djaydino on August 11, 2018, 11:37:27 PM
Hi.
You can place events into animations.

I am not on my pc now (on my phone)
But here is a link to a video about this:

If the link does not work, google for : playmaker animation event
Title: Re: Get Animator State Last Frame
Post by: Fat Pug Studio on August 12, 2018, 05:41:37 AM
I don't think it works with dropdown menu anymore, you have a box in inspector to write it down, buah. I'll check it out anyway, seems most elegant.
Title: Re: Get Animator State Last Frame [SOLVED]
Post by: Fat Pug Studio on August 13, 2018, 08:06:37 AM
Here's how it looks right now, pretty shitty but it works. I don't know how, but it works, at least with global events. Amazing.

(https://s8.postimg.cc/ynsc29al1/image.png)