Gravity

Blitz3D Forums/Blitz3D Beginners Area/Gravity

Terry B.(Posted 2007) [#1]
Anyone know a really nice and easy way to do gravity? I've tried making it just translate down, but it looks cheesy....


hockings(Posted 2007) [#2]
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


H&K(Posted 2007) [#3]
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)


Stevie G(Posted 2007) [#4]
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