Sign in to follow this  

Simple 2D ball spinning off a wall

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

Hi guys,

In my game, basic spin would go a long way towards making the game look the part. By basic spin - I mean basic. I don't want the spin to actually affect the way the ball bounces, I just want it to look as if by bouncing off wall, the ball has started to rotate.

Here:
https://img.skitch.com/20101224-msntium19gqg8irsfq33txufub.png

If any one could look give some help with this it would be great.

Thanks.

Share this post


Link to post
Share on other sites
Then you need some basics in physics my friends! Ask yourself WHY do a ball spin when you throw it at a wall. Simple. Friction.

If you want to do a quick approximation without calculating the real thing, you could simply use the angle between your ball speed vector and the normal of the wall. If the ball is coming at a 45 degree angle, make the ball spin more if in comes at anything in between, make it spin more or less. 0 degree and 90 degree is no rotation. You can also reduce the spin at every ball bounce by 50% or something. It won't be realistic but it's better than a completely rotation free world.

If you want the real thing, it's more complicated. You'd need to calculate stuff like friction, bouncing coefficient and torque.

Friction is the strength that a surface put on an object that prevent it from moving. For example, if you push a box on the floor, there's friction applied to the bottom of the box that make the top easier to push than the bottom. Friction depend on the texture of both the surface and the object, the surface in contact, its mass, etc.

The Bouncing Coefficient is how you calculate how much your ball deform when it bounce.. and its strenght at bouncing back to its normal shape. If you take a deflated ball, it will bounce less because there's less bouncing coefficient but it'll spin more because there's more surface touching the ground when it bounce. It's the same with racing tires. Deflating them will make them have more friction because they touch the ground in a wider area. It'll also heat more because of friction and hot tires are sticky on the road.. they even leave some of its material behind (tire marks).

Torque is a twisting force. When you trow a ball at a wall, there's nothing restraining the ball. Therefore, it'll start spinning on its center of mass. It'll start spinning because one side of the ball (the side touching the wall) will be slower than the side not touch it. Therefore, when you calculate the friction, you can also calculate the torque force that you put on the ball. If your ball is round and uniform, it'll spin on its center. If you take a football ball, it's harder to calculate because the ball is not uniform and will spin in a more random pattern. The bouncing coefficient is also different depending on the part of the ball that touch the surface.

Check the net. All the formulas are there.

Share this post


Link to post
Share on other sites
I think this can be done well without being complicated. Let's make an important assumption: the part of the ball that touches the wall "sticks" entirely and does not slide at all. Then, consider a ball coming in at an angle to the wall. Suppose it collides with Vx velocity parallel to the wall and Vy velocity perpendicular to the wall (use a dot product with the wall's normal to compute these - or just look at the x or y components of velocity if th wall is vertical or horizontal).

When the ball bounces, only the Vy component should be affect, the Vx should stay the same. Then the edge of the ball needs to move with velocity -Vx relative the center of the ball in order to have net velocity of zero relative to the wall. But since the ball is a circle, we know that V = omega * r where V is the velocity of the contact point (ie, -Vx), omega is the angular velocity (ie. the rate of change of the angle of the ball given in radians) and r is the radius of the ball.

That's all you need! After a collision, set the ball to be rotating at a rate of omega = -Vx / r. Hope that helps.

Edit: I just realized that this might be in 3D, in which case we just need a bit more work. Ask if you need that.

Share this post


Link to post
Share on other sites

This topic is 2545 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this