Gravity

Blitz3D Forums/Blitz3D Beginners Area/Gravity

Anyone know a really nice and easy way to do gravity? I've tried making it just translate down, but it looks cheesy....

You'll want to modify your value to suit

Gravity#=-9.8
ObjectYSpeed#=0

In each game Loop
If the ObjectY is not on the ground, then
ObjectYSpeed# = ObjectYSpeed + Gravity
ObjectY = ObjectY + ObjectYSpeed

In this way it will accellerate the Y movement towards the ground by 9.8 per game loop

lol
but as hockings said you might as well make it = 10
And it will be a vector, so x+0 z+0 and y plus or minus 10
(which I know is an arbitary difference, but you are working in 3d)

Unless you want your avitar to rocket to the earth faster than a bullet from a gun I suggest having either a constant timestep variable or use some sort of deltatiming method.

This is just contant ..

Const Gravity# = -9.8
const TimeStep# = .05

;each loop
If ObjectY is not on ground, then
ObjectYSpeed# = ObjectYSpeed# + Gravity * ( TimeStep * TimeStep )
ObjectY# = ObjectY# + ObjectSpeed * ( Timestep )


Stevie