Football (soccer) physics

Started by
2 comments, last by Gian-Reto 9 years, 9 months ago

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!

Advertisement

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.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

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.

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

This topic is closed to new replies.

Advertisement