playMaker

Author Topic: Quick Keypress question  (Read 2396 times)

greg

  • Junior Playmaker
  • **
  • Posts: 68
Quick Keypress question
« on: February 12, 2013, 12:04:30 PM »
Hey, i had a car i wanted the player to enter.

- on key down E (enter car)
- now we're in the "driving" state, on key down E (exit car)

..you can probably guess the problem, the key would be down when it entered the "driving" state, and so it exited the car immediately.

My quick fix solution: on key down E (go to "key up?" state), when in "key up?" state if key is up go to "driving state"

So only when the player releases E, do they get into the car. Is there a smarter way to do this, when it checks if the key is actually pressed, not just down?

Thanks guys, this is a really helpful community!

julius

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Quick Keypress question
« Reply #1 on: February 12, 2013, 03:12:53 PM »
If you use Get Key Down to it should only run once per press.

greg

  • Junior Playmaker
  • **
  • Posts: 68
Re: Quick Keypress question
« Reply #2 on: February 13, 2013, 03:31:05 AM »
I have an FSM "player interaction" which sends global transition: "Interacted", to the car FSM.

On car i have IDLE, and DRIVING. Where Idle is empty (but has "interacted" event that makes it go to the  driving state), and on DRIVING if "get key down E" it returns to IDLE.

^ this was resulting in it getting in the car, and immediately out.. any idea why, if you're correct about get key down only running once?