playMaker

Author Topic: stop moving the player when a certain animation is playing  (Read 323 times)

aru1310

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
stop moving the player when a certain animation is playing
« on: October 08, 2018, 08:54:14 AM »
i want to to disable the player control when the player is having a certain animation played. For example say the player has a get up animation and then it goes to idle animation i want the player to only control after it comes to the idle animation. help!!!

daniellogin

  • Junior Playmaker
  • **
  • Posts: 73
    • View Profile
Re: stop moving the player when a certain animation is playing
« Reply #1 on: October 09, 2018, 02:31:08 AM »
They say not to use Set Property unless you really really need to... but that's a (bad practice) option.

I'm guessing you didn't make the controller yourself? Otherwise you could put a global event in it to side track into an idle state and another to go back again to the main sequence, based on other FSM's doing a Send Event action.

So basically what ever is telling the animation to start could also do the Send Event to your controller (if you made that with Playmaker). For another... bad practice....option, you can have an FSM checking the Animator variable to monitor when you are starting the animation from that end. Basically to start an animation you would send a variable to the animator and it would go from there. So if something was watching Every Frame (that's that bad part, performance wise) that variable it could then do the send event or set property to the player controller.


Or just wait until someone who knows good practices to answer you :)


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3651
    • View Profile
    • jinxtergames
Re: stop moving the player when a certain animation is playing
« Reply #2 on: October 09, 2018, 06:19:28 AM »
Hi.
You probably best of to build your own controller.

But you can try "ToggleComponent" you can find it on the Ecosystem

To enable/disable the controller component

Thore

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: stop moving the player when a certain animation is playing
« Reply #3 on: October 09, 2018, 02:23:35 PM »
This is easy, but the details matter. In principle, go to the FSM that makes the character move. Add a separate state without actions. Add a global event, called say, “STOP” connected to the new separate state. Now you can set the FSM to this empty state, disabling the inputs for a while from somewhere else. You can do this from another FSM, or send the event also from the animation in quesion.

By animation: Go to the animation clip, add an event to the animation timeline (find the tiny button above the list of gameobjects that are animated). Find SendEvent, and send “STOP” (i.e. the global event that puts movement in an idle state).

Now you need to worry about how to give control back. You can do the same in reverse, e.g. “MOVE” SendEvent at the end of the animation that sets the state back to move (and a “MOVE” global event going in at the right place where it listens to buttons/axis). The danger is that with blending animations, the reset part isn‘t executed.
 
Another way is through a second FSM, let’s call it “stopper”, without involving animation clips (probably better). I assume you tell animator anyway when to play a certain animation. Say, you want that no movement is possible during attacking. When you e.g.  set the animator bool “isAttacking” you can as well send event to the stopper, and it takes care of suspending the player input. When you also know when attacking ends, you can likewise send event to stopper to restore movement controls. The stopper functionality can also be on the FSM that deals with the mechanic (attacking in my example). But you will get into trouble when multiple FSMs use the same technique. Then you want a separate FSM that manages this.

Now some details. The stopper FSM could disable/enable the movement FSM or script altogether, but that can get wonky with physics. Another way is to set the multiplier on the set velocity action to zero, and back when done (provided you use that). Instead of using an event to restore movement, you can also use a simple wait action, if you know the time, i.e. event sets it to the empty state, it waits there and when finished, go back to normal, START etc.

I use a stopper FSM. The gist is this: the jump FSM tells the stopper to stop movement for 0.2 seconds. The stopper FSM then gets the movement multiplier from the movement FSM (to store and reset later), then sets it to zero, and it then waits, using the 0.2 seconds until it sets the multiplier back to the original value I stored, resetting the functionality.
« Last Edit: October 09, 2018, 09:30:11 PM by Thore »

daniellogin

  • Junior Playmaker
  • **
  • Posts: 73
    • View Profile
Re: stop moving the player when a certain animation is playing
« Reply #4 on: October 09, 2018, 08:11:22 PM »
Hi.
You probably best of to build your own controller.

But you can try "ToggleComponent" you can find it on the Ecosystem

To enable/disable the controller component
I've heard (probably from you, or one of the other regular knowledgeable peeps here) that 'Set Property' should be limited to a last resort. So how much better/different is ToggleComponent? I mean especially in the case where the Set Property action is used to target a component and change it's Active status on and off?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3651
    • View Profile
    • jinxtergames
Re: stop moving the player when a certain animation is playing
« Reply #5 on: October 10, 2018, 01:44:25 AM »
Hi.

The get/set property is 'mirroring' every thing
so it gets all the data and then looks what can be used

the Toggle Component works directly to the component placed in the variable


daniellogin

  • Junior Playmaker
  • **
  • Posts: 73
    • View Profile
Re: stop moving the player when a certain animation is playing
« Reply #6 on: October 10, 2018, 05:06:18 AM »
Hi.

The get/set property is 'mirroring' every thing
so it gets all the data and then looks what can be used

the Toggle Component works directly to the component placed in the variable
Thanks for the info. I'll have to go grab that action from the Ecosystem then. I'm actually doing exactly what OP is asking about in my current personal project. I'm using the Standard Asset fps controller as a base which other stuff is layered on top of and have it switching on and off for an automated attack (moves the player to a target and plays an animation for a melee stab) and also for when the inventory menu is pulled up (as an overlay which needs control of the mouse taken away from the controller).

Yeah I should make my own controller, but last time I did I couldn't get jump to work right so yeah, easier to just use what's working fine for now and build features around it.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3651
    • View Profile
    • jinxtergames
Re: stop moving the player when a certain animation is playing
« Reply #7 on: October 10, 2018, 06:07:39 AM »
Hi.
I might look into making a tutorial on player controls.
As i feel many people have issues with making then.

One of the most common i see from clients of me that they tend to put almost every thing in a single fsm. (even i did that when i started with playmaker)

Also lack of parenting i see a lot.

daniellogin

  • Junior Playmaker
  • **
  • Posts: 73
    • View Profile
Re: stop moving the player when a certain animation is playing
« Reply #8 on: October 10, 2018, 07:56:24 AM »
Hi.
I might look into making a tutorial on player controls.
As i feel many people have issues with making then.

One of the most common i see from clients of me that they tend to put almost every thing in a single fsm. (even i did that when i started with playmaker)

Also lack of parenting i see a lot.
Moving is easy enough, especially because there is a thing for it. The mouse look already has a thing for it too. I figured out how to set up the movement for an Xbox 360 controller and even made it rotate/look with the right stick without much issue (after I figured out the mapping issues, aided by the asset InControl) but it was adding jump that stumped me at the time.

So if you do make a tutorial or something, please do include how to jump.

On a different note, is it normal that ducking and leaning would be handled by animations? That's what I've got set up in my current project. The camera is inside the animated objects so moves the first person view around. It also means the colliders are following what the player sees from.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3651
    • View Profile
    • jinxtergames
Re: stop moving the player when a certain animation is playing
« Reply #9 on: October 10, 2018, 08:22:56 AM »
Hi.
The thing is that the thing is not made for jumping and ducking ;)

But yes i will include  fly/duck/jump/dash/attack/2d/3d and any other things  like camera setups slope and more.

I think i will split this in a few tutorials.

aru1310

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: stop moving the player when a certain animation is playing
« Reply #10 on: October 10, 2018, 09:58:08 AM »
Hi.
The thing is that the thing is not made for jumping and ducking ;)

But yes i will include  fly/duck/jump/dash/attack/2d/3d and any other things  like camera setups slope and more.

I think i will split this in a few tutorials.

That will be wonderful please do leave a link to your youtube channel so that we can be notified once you make the videos. cheers!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3651
    • View Profile
    • jinxtergames
Re: stop moving the player when a certain animation is playing
« Reply #11 on: October 10, 2018, 07:58:22 PM »
Hi this is my youtube channel : https://www.youtube.com/jinxtergames

you can subscribe to it to get notified when new videos are added :)