Jump to content
• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# Ball flight simulation

This topic is 6169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

How can I simulate the physical correct ball flight for the Volley-ball game.

#### Share this post

##### Share on other sites
Advertisement
A rather wide question!

Firstly get a physics book which deals with the motion of projectiles.
Secondly, convert the projectile equations of motion into discrete form with a discrete time interval.
Thirdly, code the equations in whatever language you are using.

Once you''ve attempted this, come back and ask a more pointed question.

henry

#### Share this post

##### Share on other sites
Yeah, henryx is right. Start small. If you write a simulator that just treats the ball as a simple projectile it''ll probably be good enough. The big challenge will not be simulating the projectile flight path, but in detecting and responding to collisions (with the ground, players hands, ...).

Anything beyond simple projectile motion for a volleyball might not be noticeable on screen, but if you really want to go extreme you could include the effects of airflow (drag, and lift if the ball is spinning), the effect of the deformation of the ball. Perhaps the most important effect to add beyond simple motion would be decent friction forces in the collision response. That''s a deep subject, and you should get the basics working first.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

#### Share this post

##### Share on other sites
quote:
Original post by henryx
A rather wide question!

Firstly get a physics book which deals with the motion of projectiles.
Secondly, convert the projectile equations of motion into discrete form with a discrete time interval.
Thirdly, code the equations in whatever language you are using.

Once you''ve attempted this, come back and ask a more pointed question.

Hmm, thanks, daddy but I don''t want to invent the bicycle again, may be there are some kind of sources, which can show it to me???

#### Share this post

##### Share on other sites
Just do a search for Projectile Motion.

#### Share this post

##### Share on other sites
Projectile motion, neglecting air resistance, is pretty simple. There is just a constant force being applied to the ball downward, which makes it accelerate downward. The x/z component of the velocity remains constant.

Then you need to simulate bounces. To do this, just scale your vector by -1. This is far from being an accurate physical simulation (unless your tennis ball is a subatomic particle, lol), but it should be decent for your purposes.

The ball, though, as you can see, will keep on bouncing forever. You may want to just scale the velocity by 0.02 every time it bounces or something. It's kind of a hack, I know, but it should suffice.

Now, in slightly more understandable English:

The ball moves along the x axis a certain amount each second, along the y axis a certain amount, and along the z axis. These three numbers (called the axial components of a vector ) are stored, and are added to the ball's xyz coordinates each frame/second/timestep. You subtract a fixed amount from the vector's vertical component each timestep to simulate gravity. Then, if the ball's vertical coordinate is below 0 (we'll say the court is a horizontal plane at 0) then you multiply the x and z components of it's vector by -1 for a perfectly elastic bounce (if a rubber ball never stopped bouncing) or by a negative number greater than -1 like -0.5 to make it lose some energy. In real life, in an inelastic (the ball doesn't bounce back with quite as much force as it hit the ground) collision, it wouldn't bounce back in exactly this direction, but this should work well enough. Then, when the player hits it with a racket, you'll need to determine what direction it was hit in, and add that force vector to the ball's velocity vector. When the components of the ball's velocity are all 0, the ball is "dead."

I hope that helps.

I'd still recommend, as henryx did, though, to get a physics textbook!

Edited by - TerranFury on November 3, 2001 6:02:58 PM

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5
• Advertisement

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632630
• Total Posts
3007526
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!