playMaker

Author Topic: How do custom events and transitions work?  (Read 2328 times)

Encore

  • Playmaker Newbie
  • *
  • Posts: 2
How do custom events and transitions work?
« on: August 24, 2021, 07:13:44 AM »
I'm making a 2D game and I want to use Playmaker as I do not know much about coding. There's definitely a learning curve but your tutorials have been very helpful for the most part, yet I'm still lacking some basic understanding of events and transitions.   

For example, I use the GetKeyDown action to start a conversation. That action has a send event option which I assign to the FINISHED transition that leads to the Start Dialogue state (link to screenshot http://prntscr.com/1qgsndi).

Following the same logic, I want to use the GetAxis action that leads to a Movement state that has the Get Velocity 2D action. I reckon this is how I'm supposed to set up my character's horizontal movement.

However, there's no Send Event on GetAxis, and none of the system events fit, so I do not know how to correctly transition to the Movement state. I can only assume I need to create a custom event, but here's where I am a bit fuzzy, cause I did not find a tutorial that covers custom events.

So, what I am supposed to do if there's no Send Event option and none of the system events suit me? And if this is not the right way to set up a movement scheme, what is?

Any help would be much appreciated!



djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do custom events and transitions work?
« Reply #1 on: August 24, 2021, 05:09:28 PM »
Hi.
FINISHED is a default event.
it will be triggered if all your action are done (actions with every frame disabled or only trigger once)

Get Axis and Set (not Get) velocity can be in the same state.
Check 'Every Frame' on them.

maybe this tutorial series can help :

https://hutonggames.com/playmakerforum/index.php?topic=22352.0

Encore

  • Playmaker Newbie
  • *
  • Posts: 2
Re: How do custom events and transitions work?
« Reply #2 on: August 25, 2021, 03:51:51 PM »
Hi.
FINISHED is a default event.
it will be triggered if all your action are done (actions with every frame disabled or only trigger once)

Get Axis and Set (not Get) velocity can be in the same state.
Check 'Every Frame' on them.

maybe this tutorial series can help :

https://hutonggames.com/playmakerforum/index.php?topic=22352.0

Thanks, I found another tutorial that sort of helped but I have one more question if I may. I'm using A and D keys to flip my character's horizontal scale, but unfortunately, I can hold D to move right and then press A and my character will keep moving right but its mesh will flip left - and vice versa. Is there any way to prevent that?

I know that the tutorial you posted does offer a solution by creating a second FSM and flipping the sprite's property, but I use characters animated in Spine and these do not use the sprite renderer component, they have meshes instead.
« Last Edit: August 25, 2021, 03:55:06 PM by Encore »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do custom events and transitions work?
« Reply #3 on: August 28, 2021, 01:47:29 PM »
Hi.
Can you show your setup.

its good to use multiple fsms.

you can for example setup a movement fsm.

when axis is negative go to state 'move left' there you compare if axis is 0 or positive.

and go to right state or idle state.
in those states have a Set Bool Value. (call It 'Left' for example)
in left state, set it 'true' in Right state set it 'False.

now on the 2nd fsm 'Turn'
you can do a Get Fsm Bool and do a bool test on it (set every frame)

you can have 2 states (for left an right)
when true go left state, when false go right state.