My 3d tennis game is currently more like a 2d tennis game as my ball never uses gravity for its y values at the minute, it moves only left and right and forward and back, not up and down. I have the collision detection pretty much sorted for all the objects and the ball stays within its confines. As soon as i introduce gravity my ball is apparently colliding with floor level even though i am not checking for a collision like this :s
and as soon as it bounds of the floor it just flies up in the air and doesnt come back down, now my understanding is that gravity is a pretty simple effect to achieve even in 3d, just a case of decreasing the y values of an object by however many units per second or something. This is exactly how i implemented it
CODE
// this is called in the update function for the ball(every frame), it moves the ball in x
// and z by adding to the values by delta time * the cos of angle0 * the ball speed, angle0 is a value returned by my
// reflect function, which gives realistic bouncing angles from players and barriers
x0 += dt * cos(angle0) * BALL_SPEED;
z0 += dt * sin(angle0) * BALL_SPEED;
y0 -= dt * BALL_SPEED;
then when the ball reaches floor level its y increases by a certain amount to give the bounce effect
should work right :s
i have even tried hard coding a max y for the ball that i thought might bring it back down, i even tried some boolean variables for climbing and falling, i have no clue why it doesnt want to work
any help is greatly appreciated, im using c++ and opengl
thanks