playMaker

Author Topic: How would I play an animation when player dies? [SOLVED]  (Read 4632 times)

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
How would I play an animation when player dies? [SOLVED]
« on: March 26, 2014, 05:16:01 AM »
I'm having a hard time getting an animation to play when my character dies. I have an animator with a death animation inside. How would I go about playing that when health = 0? (Already have the health = 0 check done, just need to figure out animation.)

Any information is appreciated.
« Last Edit: March 27, 2014, 07:09:00 PM by spacerobot »

xhidnoda

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Re: How would I play an animation when player dies?
« Reply #1 on: March 26, 2014, 07:23:26 AM »
1. For example, make a "Listener FSM" on you health. When the health is 0 just play animation.
2. Or you can just make a global event "Play Dies Animation". So, when you health = 0 send event to another(or self) FSM contain the "Play Dies Animation" event.

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #2 on: March 26, 2014, 07:29:04 AM »
I guess I'm looking on how to actually play the animation. I have an animator controller for my player. That has my run, jump, death animations etc. So what would my gameobject be that would play the animation? Would I use playanimation or  aniamtorplay? I've tried both and haven't had any luck.

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
    • View Profile
Re: How would I play an animation when player dies?
« Reply #3 on: March 26, 2014, 07:33:54 AM »
You would do play animation

You need to select the GameObject that actually has the animation component on it and then write in the name of the animation to be played...This would need to be case sensitive.

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #4 on: March 26, 2014, 07:38:50 AM »
Thanks for getting back to me. I appreciate it.

So I cannot add the animator controller to the play animation action. Do I need to get that and store it somehow as a variable or something?

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
    • View Profile
Re: How would I play an animation when player dies?
« Reply #5 on: March 26, 2014, 07:44:01 AM »
Having some playmaker issues so cannot do in front of me, this is off the top of my head so I hope its right :)

What I tend to do is;

I have 2 Game Objects;

* Character (With animations component)
* Health manager

On the character FSM I would have set "Get Owner" action and set Global Variable to something like "PlayerGO"

You could then have the listener action "Listen_For_Death" - Create a global event "Player_Death_Animation"

This then leads to the next state "Player Died Animation"

Set the action Play Animation - Select the death animation you want to play. (This must be in the animations list in the component)

On the Health Manager, when you get to the action were you want to play the animation.

You do a "send event" action, set the PlayerGO global variable as the target Game Object. The FSM you want to use on that player Game Object and then the global event

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #6 on: March 26, 2014, 08:24:25 AM »
Thanks for the info. I think I am close, but it is still not playing the animation. Is there anything inside the listen state? Or does that just hook to the play death animation state?

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
    • View Profile
Re: How would I play an animation when player dies?
« Reply #7 on: March 26, 2014, 08:25:39 AM »
Nothing in the listen state - it simply has the global transition, which leads to the play death animation state.

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #8 on: March 26, 2014, 08:45:29 AM »
Hmmm. It still isn't playing the animations. Do these look right for the states for the end of the health manager and player (attached)?


lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
    • View Profile
Re: How would I play an animation when player dies?
« Reply #9 on: March 26, 2014, 08:50:08 AM »
On your send event you have it set as FSM, where as the FSM you have the listener on is FSM2

On the get owner state, put a finished transition and then link this through to the listener

On the actual play animation, have you tried;

* Setting Game Object as the global variable player
* tried setting Game Object as owner


spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #10 on: March 26, 2014, 10:28:18 AM »
Thanks.

I fixed the FSM2 naming and added the Finished state transition to the set global.

When I change the animation to use the global var it says there are no animations available. When I select the player object though they are all listed.

EDIT: Also I see that everything is working between the two FSM's and the state is making to the final Player died animation state on the player object.

So close! Something is still off though.
« Last Edit: March 26, 2014, 10:36:52 AM by spacerobot »

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
    • View Profile
Re: How would I play an animation when player dies?
« Reply #11 on: March 26, 2014, 10:55:01 AM »
Can you attach a screenshot of the players inspector?

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #12 on: March 26, 2014, 11:08:30 AM »
Here is the player inspector.

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
    • View Profile
Re: How would I play an animation when player dies?
« Reply #13 on: March 26, 2014, 11:23:00 AM »
I dont have the animator, are you using legacy animations?

spacerobot

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
Re: How would I play an animation when player dies?
« Reply #14 on: March 26, 2014, 11:38:25 AM »
The death animation is legacy.

Could my character controller script be interfering with this since it is controlling the character and not playmaker?