Please check my *very* simple 3D physics code - its not working!

So I’m not exactly a whiz with physics. I did once write a 2D physics engine which, while being very messy, worked to my needs.
And when I say physics engine, I mean getting a player to jump, fall down with gravity, and land on a surface that was below it’s feet.
It would’ve been extremely easier if I had that 2D ‘physics’ engine to refer to, but due to severe, irreversable stupidity, that small set of code is sitting at a computer desk about 600 kilometers away.

So here is what I have so far. I can move about on an x and z axis, detecting collisions with a cuboid. I can jump on a spot, loose upwards momentum with gravity, fall, and land. I can jump ontop of the cuboid. Observations say that my Y position stops as soon as I am above the cuboid, however, my yBottom variable does change to the correct height when atop the cuboid. I cannot jump from the cuboid, because the Y position is not the same as the yBottom. yBottom is the highest point of geometry at my x/z coordinates.

The code

If you can point out my obvious errors amongst my poorly(?) structured code and help fix my little problem, that would be great!

Thanks

bump.
still waitin’… :emo:

This place is world-wide so I’d wait at least 24 hours…

He did wait 13 days, I think that should be enough.

:frowning:

Apologies sauce, for some reason I read both posts as being from today.

I’d say the problem is related to

if(world.keys[Keyboard.KEY_SPACE] && onGround){
onGround = (vector.y == yBottom);

Do you allow double jump? If not, why don’t you say something like?

if(world.keys[Keyboard.KEY_SPACE] && !jumping){

I hope someone can help you soon, I just couldn’t read the code thoroughly because I’m at work :frowning: