playMaker

Author Topic: Smashing into loop limit[SOLVED]  (Read 2037 times)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Smashing into loop limit[SOLVED]
« on: April 29, 2013, 01:52:39 PM »
I am following what I think is a simple and straightforward procedure to impress acceleration to a wheel.

I check if a key is down.
If it is, I move to another state, where a float is keeping updated by adding 10 force each second.
At the end of this state I have a float compare.
If the acceleration variable goes over 50, I go to another state to set it back to 49.

Of course, 1000 cycles run off in a moment and also raising the limit does not solve the problem.

How do you behave in this condition???
« Last Edit: April 29, 2013, 03:12:28 PM by jeanfabre »

greg

  • Junior Playmaker
  • **
  • Posts: 68
Re: Smashing into loop limit
« Reply #1 on: April 29, 2013, 02:13:28 PM »
Store KeyDown as boolean
convert bool to float : 10 or 0 (add amount)
add "add amount" every frame
clamp "acceleration" between 0 - 50
multiply acceleration by 0.9 (deceleration) every frame


Might not help you, but this is how i handle acceleration within a single state.

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Smashing into loop limit
« Reply #2 on: April 29, 2013, 02:40:43 PM »
Thank you, Greg, that's great!
What I was missing was the CLAMP command, I'm old style and using IF/THEN all the time eheh  ;D  >:(