playMaker

Author Topic: Get PlayMakerGUI elements to respond to Unity Button input instead of Mouse  (Read 3134 times)

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Is this even possible without forgoing PlayMakerGUI entirely and using scripts instead?
I want to map, for example, GUI button selection to GetInput.Axis("Vertical")

Am I right in thinking it looks like PlayMakerGUI is very limited at the moment to only Mouse and Touch input?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 Playmaker doesn't really constraint you in that regards, you are free to mix scripts and playmaker in your scene at will. and eve script custom actions to achieve a specific feature of course.

 As for mixing inputs, My excavator simulation does that. you can control the excavator using inputs, or the remote control made of gui sliders.  AND they are binded, that is as you control it with a joystick, you'll see the gui sliders moving accordingly, all it tightly binded together :)

Basically, you need to write a custom input "broker" as a singleton and modify all your scripts to actually use that singleton instead of the unity input manager.

 SO let's say we call our singleton "InputBroker"

Nothing else in your scene should directly access the Input anymore, creates method that ressemble the Input Api and pass information back, so if the use want to access the "jump" input, call InputBroker.GetAxis("Vertical") that in turn will call Input.GetAxis ("Vertical")

now, since you want a button to act as input, it becomes a bit more difficult, but basically you will have to tell your InputBroker that a particular input value as changed, you record the new value and when you query it, you give that value instead of the one from the Input. This is the basic principle.

so :

when the gui button is pressed call Inputbroker.SetButtonDown("jump") and make this information last one frame ( cause this is how it works for the Input.GetButtonDown)

then if someOneQuery InputBroker.GetButtonDown("jump"), you look first in your data if indeed this input down, else you forward the Input.GetButtonDown(), cause it might be true actually).

That's the basic principle, it goes further for a solid implementation, but you get the idea.

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
me again.

 one more thing, to integrate this in playmaker, you will then need to create the same actions to access Input and simply access your InputBroker instead like "GetAxis" for example.

Bye,

 Jean