V
Vetmatt89
Guest
Hey all whom use this forum! I was wondering if someone can help me tackle a problem? I have my acceleration and deceleration working the way I want it. I have a "sprint" button as well.
The problem that I'm having is my speed won't decelerate to the desired number, but instead jump to that number. I will post my code up and hopefully someone can help me out! Please and thank you!
if (move == 2)
{
hsp += 0.06
if (hsp > 1.3) && (key_run == 0) hsp = 1.3
}
if (key_run) && (hsp > 1)
{
hsp += 0.06
if (hsp > 2.2) hsp = 2.2
}
if (move == 0) && (hsp > 0)
{
hsp -= decel
if (hsp <= 0) hsp = 0
}
if (move == 2) && (key_run == 0) && (hsp > 1.3)
{
hsp -= decel
}
The problem that I'm having is my speed won't decelerate to the desired number, but instead jump to that number. I will post my code up and hopefully someone can help me out! Please and thank you!
if (move == 2)
{
hsp += 0.06
if (hsp > 1.3) && (key_run == 0) hsp = 1.3
}
if (key_run) && (hsp > 1)
{
hsp += 0.06
if (hsp > 2.2) hsp = 2.2
}
if (move == 0) && (hsp > 0)
{
hsp -= decel
if (hsp <= 0) hsp = 0
}
if (move == 2) && (key_run == 0) && (hsp > 1.3)
{
hsp -= decel
}