playMaker

Author Topic: [SOLVED] Issue with Get Button Down Send Event  (Read 2741 times)

hockeygoalie78

  • Playmaker Newbie
  • *
  • Posts: 8
[SOLVED] Issue with Get Button Down Send Event
« on: January 22, 2020, 11:09:07 AM »
I have set up a global event that is used by a global transition in one of my FSMs, but when I attempt to put it in the send event slot of the Get Button Down action in another FSM, I get an error saying that it is not used in any global transition. Is there a way to get the global transition to detect it without having to use a separate state/action?
« Last Edit: January 23, 2020, 02:50:09 PM by hockeygoalie78 »

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Issue with Get Button Down Send Event
« Reply #1 on: January 22, 2020, 01:22:14 PM »
On your game object that contain your ui button, check the "Button" Component. see there is an On Click() below navigation. Add + and drag the fsm gameobject that contain your global event

select playmaker fsm Send Event and enter the string of your global event name.

it will be triggered everytime user click the button.

hockeygoalie78

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Issue with Get Button Down Send Event
« Reply #2 on: January 22, 2020, 01:28:55 PM »
On your game object that contain your ui button, check the "Button" Component. see there is an On Click() below navigation. Add + and drag the fsm gameobject that contain your global event

select playmaker fsm Send Event and enter the string of your global event name.

it will be triggered everytime user click the button.
Perhaps I phrased my original message poorly; I am referring to the Get Button Down action that detects input rather than an action for a UI Button. My goal is to make that keyboard input trigger a transition to another state early and trigger a state change in a different FSM simultaneously.

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Issue with Get Button Down Send Event
« Reply #3 on: January 23, 2020, 12:46:39 AM »
It would be helpful if you could send a screenshot on what you want to do

for example if you just want to send event by using keyboard get key down, you could just do
get key down x > send event (Your global event) broadcast all / specific certain fsm

so it goes like this

State1
Get key down < Transition to > state 2

state2
Send event > broadcast all > your global event

hockeygoalie78

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Issue with Get Button Down Send Event
« Reply #4 on: January 23, 2020, 09:41:54 AM »
It would be helpful if you could send a screenshot on what you want to do

for example if you just want to send event by using keyboard get key down, you could just do
get key down x > send event (Your global event) broadcast all / specific certain fsm

so it goes like this

State1
Get key down < Transition to > state 2

state2
Send event > broadcast all > your global event
That might be what I end up having to go with, but I'm hoping to cut out the extra step if possible. Essentially I want to set it up like this:
https://imgur.com/a/A8kp7E4
I want to play the video in the state, then have it transition to the next state either when the video ends or when the player hits the button for the skip input. The SkipVideo event does work on the local FSM but I want another FSM to be able to detect that.

hockeygoalie78

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Issue with Get Button Down Send Event
« Reply #5 on: January 23, 2020, 02:49:43 PM »
I was able to solve this issue. I changed the GetButtonDown action slightly to add a public FsmEventTarget and triggered the event in a similar manner to the SendEvent action. This allowed me to choose which FSMs to broadcast the event to.
Code: [Select]
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Input)]
[Tooltip("Sends an Event when a Button is pressed.")]
public class GetButtonDown : FsmStateAction
{
[RequiredField]
        [Tooltip("The name of the button. Set in the Unity Input Manager.")]
public FsmString buttonName;

[Tooltip("Where to send the event.")]
public FsmEventTarget eventTarget;

[Tooltip("Event to send if the button is pressed.")]
public FsmEvent sendEvent;

        [Tooltip("Set to True if the button is pressed.")]
[UIHint(UIHint.Variable)]
public FsmBool storeResult;

public override void Reset()
{
buttonName = "Fire1";
sendEvent = null;
storeResult = null;
}

public override void OnUpdate()
{
var buttonDown = Input.GetButtonDown(buttonName.Value);

if(buttonDown)
{
Fsm.Event(eventTarget, sendEvent);
}

storeResult.Value = buttonDown;
}
}
}

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: [SOLVED] Issue with Get Button Down Send Event
« Reply #6 on: January 23, 2020, 10:42:53 PM »
Hi.
It is best to rename your action (Class and file) and place in in a custom action folder (outside playmaker folder)
Because if you would update playmaker, the changes will be overwritten.