playMaker

Author Topic: Holding key down/ get key up  (Read 1312 times)

D_Neville

  • Playmaker Newbie
  • *
  • Posts: 2
Holding key down/ get key up
« on: March 05, 2019, 01:07:32 PM »
Having a slight issue using the get key functions to create a player control for a Simple 2d game.
The idea is you hold a key down to build up momentum on an obstacle course so there is more needed than just an on/off

In a simple FSM the get key functions worked as expected, however now there are extra states, unless I release the key at the exact moment it seems to not register the interaction.

As a work around I tried making the key down/key up functions alter a global bool then have a bool check on the add force functions, but it still doesn't register the input.

What's the best way to recrtreate 'get key down?' 

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Holding key down/ get key up
« Reply #1 on: March 05, 2019, 06:33:44 PM »
Hi.
You should use multiple fsms for this, and also use get/set fsm actions.

There are even more useful fsm actions on the Ecosystem

like 'fsm bool test' for example

Have the get key in a separate fsm and store the bool variable.

the you can use the 'fsm bool test' ('Check' Every Frame) to see if true or false on another fsm where you handle the speed.

you could also use 'get key down' (state 1) and 'get key up'   (state 2)

and in both states use a send event, to send a event to another fsm.

This video can help you understand how to use global events :


D_Neville

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Holding key down/ get key up
« Reply #2 on: March 06, 2019, 02:25:10 AM »
I tried making it a global function. It didn't seem to register the key up, or alter a global bool.
Any ideas?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Holding key down/ get key up
« Reply #3 on: March 06, 2019, 06:47:22 PM »
Hi,
Can you show your setup (video/images)