Sign in to follow this  

Football (soccer) physics

This topic is 1275 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

Hello!

 

I've been looking for a beginner's tutorial on football physics, but can't seem to find one.

 

I'm currently trying to find out how the ball slows down after it has been kicked (on the ground). I don't know how to implement the physics in my game.

 

So, let's say a player kicks the ball with a speed of 100 (just a variable here). How does the ball actually slow down? It's obviously not linear, as in the beginning the ball keeps its speed for quite long and then stops moving fairly fast. I've been reading articles about the physics side, but I can't think of a way to implement the actual slowing down in my game.

 

Please help me with some pseudo code. Thanks!

Share this post


Link to post
Share on other sites

IMO, this is a great place for using a 2d physics library.  chipmunk and box2d  are 2 great examples.

 

Basically, what I would do in this case is, when the ball is kicked, if it's in the air, you provide some small amount of friction, as well as gravity.  The small friction is the air friction.  When the ball hits the ground, it should perform the typical bounce, but also there should be larger amount of friction when the ball is in contact with the ground.  Once the ball is just rolling, it will use the ground's friction to slow it to stop.

 

Good luck and have fun.

Share this post


Link to post
Share on other sites

Most of the slow down at high speeds comes with drag, which scales quadratically with speed. So just have a

new_speed = old_speed - old_speed^2 * coefficient

and tune the coefficient until it feels right.

Share this post


Link to post
Share on other sites

any chance to use a physics library in your game? I know, some people like to write their own physics stuff, and I know from my expierience that more ofen than not, in PhysX you have to fight the physics more than they help you, but for easy problems like a rolling ball and friction, at least PhysX is pretty good.

 

 

AFAIK PhysX and bullet Physics are free to use?

 

 

If you are more interested in coding it yourself, or you hate putting a big library in your game, ignore my whole comment smile.png

Edited by Gian-Reto

Share this post


Link to post
Share on other sites
Sign in to follow this