playMaker

Author Topic: Get Animator State Last Frame[Solved]  (Read 271 times)

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 828
    • View Profile
    • Fat Pug Studio
Get Animator State Last Frame[Solved]
« on: August 10, 2018, 05: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?
« Last Edit: August 15, 2018, 12:30:13 AM by djaydino »

GonerGames

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
Re: Get Animator State Last Frame
« Reply #1 on: August 10, 2018, 02: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 for reference.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 828
    • View Profile
    • Fat Pug Studio
Re: Get Animator State Last Frame
« Reply #2 on: August 11, 2018, 08: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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3602
    • View Profile
    • jinxtergames
Re: Get Animator State Last Frame
« Reply #3 on: August 11, 2018, 08: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:
https://youtube.com/watch?v=xRD9GNjNBKI

If the link does not work, google for : playmaker animation event

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 828
    • View Profile
    • Fat Pug Studio
Re: Get Animator State Last Frame
« Reply #4 on: August 12, 2018, 02: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.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 828
    • View Profile
    • Fat Pug Studio
Re: Get Animator State Last Frame [SOLVED]
« Reply #5 on: August 13, 2018, 05: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.

« Last Edit: August 13, 2018, 05:21:37 AM by krmko »