LoginLogin

gravity

Root / Programming Questions / [.]

PixelStudioCreated:
Hello I'm trying to implement gravity into my movement loop, any help on how this could be done? I know it involves the Y axis but I'm not too sure how to put this in.

Y velocity = Y velocity - 1 :P

That's all?

It seems too easy Xp

Yeah then flip it to negative when it hits the ground if you want it to bounce. ( *-0.9 to account for energy lost, nothing bounces forever) If you don't want bounce just reset it to 0 when it touches ground. You can add terminal velocity (air friction) by multiplying it by a number less than one but more than 0.

Thanks :D