playMaker

Author Topic: Detecting 2 button input [SOLVED]  (Read 4090 times)

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Detecting 2 button input [SOLVED]
« on: April 05, 2013, 11:00:41 AM »
Hi! Hope everybody doing fine!
Do you guys have an idea for the best way to detect if two
buttons are touched at the same time.

When I press left my character jump left.
When I press right my character jump right.
I'd like to introduce a new action if thos 2 button are pushed at the same time.
I think a way to do it is to make a little timer that when you press say right if the left button is pushed it send the third action...

Or is their a better way?
Thank you!
i'm now on twitter too! @VictorRayDev
« Last Edit: April 05, 2013, 07:28:02 PM by Alex Chouls »

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Detecting 2 button input
« Reply #1 on: April 05, 2013, 03:40:16 PM »
I found that in code we can do something like this.

if(Input.GetButton("Fire1") && Input.GetButtonDown("Fire2") || Input.GetButton("Fire2") && Input.GetButtonDown("Fire1"));
trying to translate this into playmaker

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Detecting 2 button input
« Reply #2 on: April 05, 2013, 05:37:21 PM »
You could store each button state in a bool variables using the Get Button action then use Bool tests (e.g. Bool All True) to send events.

Quote
I think a way to do it is to make a little timer that when you press say right if the left button is pushed it send the third action...

This is also a good approach, particularly if you want to create a "timeout" for the second button press. You can break your description down into states with a timeout. See attached image.

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Detecting 2 button input
« Reply #3 on: April 05, 2013, 06:50:56 PM »
Excellent. Your second option suit what I want perfectly. Thanks Alex!