playMaker

Author Topic: [SOLVED]Track and Field arcade. Moving by tapping buttons  (Read 1194 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
[SOLVED]Track and Field arcade. Moving by tapping buttons
« on: March 28, 2020, 04:24:27 AM »
Hi,
How can I move an object, so the faster I tap buttons, the faster the object will move? Kind of like the old track and field arcade game.
« Last Edit: March 29, 2020, 06:34:34 AM by Splankton »

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: Track and Field arcade. Moving by tapping buttons
« Reply #1 on: March 28, 2020, 09:22:20 AM »
I can set the velocity x=1 every time a key is down, then on key up, set no movement. It works fine, but how do I increase the velocity with more rapid key presses?
Thanks

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: Track and Field arcade. Moving by tapping buttons
« Reply #2 on: March 28, 2020, 01:20:51 PM »
Ok, For anyone who might be interested in doing something similar, I've done this by making a float which adds a value every time a button is pressed, which decreases back to 0 as soon as its added.  Then use that float to set the velocity.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Track and Field arcade. Moving by tapping buttons
« Reply #3 on: March 29, 2020, 04:44:58 AM »
Hi.
i don't know if you set it up this way but i would use a float add and set per second.

and add for example -1 per second.
and a float clamp (set to 0 and set to a max speed)
on the same state have Set velocity and also a float compare to check if 0 or

on button fsm use 'Fsm Float Add' ([urlhttps://hutonggames.fogbugz.com/default.asp?W1181]Ecosystem[/url])on each click



The add value you could also manipulate from another fsm so that it would gradually deduct faster if a longer period no button was pressed
« Last Edit: March 29, 2020, 04:46:53 AM by djaydino »

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: Track and Field arcade. Moving by tapping buttons
« Reply #4 on: March 29, 2020, 06:33:47 AM »
Yes I have it kind of the same, except the float clamp which would be useful. Thanks