Help with Tennis Ball Physics?

Blitz3D Forums/Blitz3D Programming/Help with Tennis Ball Physics?

Gabriel(Posted 2003) [#1]
I decided to have a go at knocking up a simply 3d tennis game, and I've got some basic graphics sorted, player movement, game structure, etc sorted. But I'm having some problems deciding how to implement the ball physics.
The idea was to make it a fairly arcade-y tennis game, not ultra-realistic phyics. Something like Pro Tennis Tour, only in 3d, if anyone's old enough to remember that ;)

Initially I figured I could just give the ball an initial vector and apply air friction and gravity each physics update. But that makes the game more complicated ( and hence less fun to play ) I really want the ball to always bounce around the same length ( just inside the baseline ) and only vary that a little. Thus I need the ball arc to be approximiately the same every time, and only adjust the speed at which it moves. But on the other hand, I don't want to make it ultra-repetitive and predictable. There has to be some room for variance.

I don't really intend implementing spin at this stage. I might add it in the future, but it's probably not something I would want to add at all for a pure arcade game.

Any suggestions/help greatly appreciated.


Rob Farley(Posted 2003) [#2]
I would suggest doing exaclty what you first said...

Just use and x,y and z speed, and translate the entity by those amounts each update. Each update add gravity to the y speed. If the y value hits the ground then my y=-y*bounce# (where bounce# is how much bounce, 1 being 100% 0 being no bounce at all) I wouldn't worry too much about air friction.


Gabriel(Posted 2003) [#3]
Yeah.. I have already added the bouncing ahead of time. I have constants for each surface you can play on. I can just pull those up as I need them.

Ok, so assuming I stick with my original plan of using vectors and gravity, I need to be able to reverse it.

Is there a way to calculate the initial y and z velocities, if I have the following information :

z distance required ( the point at which I want the ball to hit the ground )

angle ( angle at which the ball is hit )

And I guess I can put time and gravity into values before I start.

Is that possible?


Oldefoxx(Posted 2003) [#4]
If you know the heighth of the ball, you can calculate the
fime for gravity to carry it to ground. Knowing the time to ground, and the distance to be covered, you can calculate the speed that the ball has to be moving at to travel that distance before it hits the ground. Deciding how efficiently the ball absorbs and returns energy (say 85%) efficient, determines how high the ball will reach on its next rise. That determines how long it will take. That determines where the midpoint of its bounce would be. And you are back pretty much to the original state, except in a different location, possibly traveling in a different direction (deflection off of a surface). For greater realizm, you might want to reduce the velocity each time it strikes a surface (the effect of friction), so as the ball bounces in lower and lower arcs, the arcs reflect a more vertical rather than forward movement.

Actually, I read that the arc or a ball or cannon shot follows a parabola, and since the math for a parabola is fairly straightforward, it might offer you another approach.


Jeremy Alessi(Posted 2003) [#5]
Look at the ball physics in the archives. Then just add a simple collision routine which assumes the ball is massless compared to the raquet for hitting the ball which automatically adds a certain about of x,y,z velocity depending on the hit and direction the player is pressing.