- Home /
Question by
Johnz1234 · Jun 27, 2015 at 12:22 PM ·
scriptingbasics
How can i limit my speed?
i tryed this but it doesn't work every time i start my game my current speed is maxspeed?
anyone who can help?
if(currentSpeed <= MaxSpeed){
current = MaxSpeed;
}
Comment
Answer by Neilos · Jun 27, 2015 at 12:34 PM
That says:
If currentSpeed is less than or equal to MaxSpeed then set current to MaxSpeed.
I think you mean to have this:
if(currentSpeed >= MaxSpeed){
current = MaxSpeed; // should this be currentSpeed not current?
}
no i don't want to be my current because my current speed is 5 when it's inccrised is 20 i want to stay 20 and if u stop then it's back to 0
I'm not sure I understand you. You may need to put more information into your question if my answer is not good enough. Also I don't understand your variable names, you have two variables alluding to "current", could you describe in more detail what these variables are and how you expect them to behave.