Advertisement

Determining Collision vs Rolling?

Started by February 17, 2003 03:09 PM
1 comment, last by SoaringTortoise 22 years ago
How can you determine whether an object has collided with another object, or whether it is simply traversing the surface of the object. For example, if you roll a ball along an undulating ground, its force vectors will almost certainly point through the ground, so you can''t use a "If Force Intersects Object" test. Similarly, when the ball encounters an uphill, its velocity will not be parallel to the ground when it encounters the bottom of the hill, but this isn''t really a collision worthy of any special action (such as playing a sound). So... I can''t use forces, and I can''t really see a way to use velocity, unless you have some kind of a threshold for the angle of incidence with the ground, and if the angle exceeds that threshold then you define the contact as collision, otherwise it is simply a rolling action. I need to know this because: 1) I want to take special action depending on whether it''s a collision or a roll, and 2) If it''s a roll, then I apply friction, but if it''s a collision then I apply restitution and reflection. Anyhow, a bit puzzled by this really. Any help would be truly useful. I can always say, "Last Object you were in contact with was X, so if this contact is not X, then this is a collision", but that seems really clunky and I could have some serious problems diferentiating between ''Ground'', ''Objects on the Ground that can cause an impact such as walls'' and ''objects on the ground that do not cause impacts such as inclined ramps''. Learning to fly is easy, but as a tortoise, the landings are really rough.
Always prey on the weak, the timid and the stupid. Otherwise you'll just get your butt kicked
For a tortoise, this is extremely hard to do, but when you get it right... the expression on their faces ...
I've been thinking about this some...

The way I do collision handling with balls/surfaces is I project the velocities on the normal, and use that to modify velocity for each object. Now, what about the component to the projection? (the part of the original velocity that is 90 degrees off the projection line) -- can that be used to determine how much rotation is applied at the point of impact?

I think you should be able to take the component and cross-product it with the normal to find torque. Unfortunately I've never gotten further than this in implementation.


also -- say you hold a ball in mid-air and start it spinning nice and fast, then drop it. The ball *should* lose a lot of the rotation speed but gain linear velocity somehow. I think that this could be done in the same section of code that deals with how much velocity is converted to rotation speed.

the way I deal with a ball traversing down a hill is that gravity pulls the object into a collision with the hill, collision handling kicks in and ends up converting the result into-the-hill velocity into a slightly faster down-the-hill velocity. I never have to manually keep track of "ball A is rolling down the hill rather than bouncing down it"

[edited by - Nypyren on February 17, 2003 4:24:47 PM]
Advertisement
OK, I tried that method, but I get some very weird results (perhaps I''m doing it wrong).

My method is like this:

1) Add up all the forces acting on the ball (Thrust, Gravity, the normal of the ground if you are on it, friction as a force opposite to the direction of motion if you are on the ground).
2) Add these forces to the ball''s velocity.
3) If the BallPosition + BallVelocity results in a collision, then reflect the new BallVelocity in the plane of that collision and reduce it by the coefficient of restitution.

Does that seem logical to you? It does to me, but I occassionally get some very weird results (like the ball accelerating UP hills... not always, just sometimes). Also, getting the ball to stop moving seems to be a problem, even though I have friction involved.

If I turn off the Ground Normal + Friction then the ball bounces exactly perfectly. If I turn off the impact reflection, then the ball rolls perfectly. If I have them both on then it gets a bit messed up. That''s why I''m looking to differentiate between a roll and a collision. But, if this approach makes sense and it''s just the implementation that I messed up, then I shall persevere.

Learning to fly is easy, but as a tortoise, the landings are really rough.
Always prey on the weak, the timid and the stupid. Otherwise you'll just get your butt kicked
For a tortoise, this is extremely hard to do, but when you get it right... the expression on their faces ...

This topic is closed to new replies.

Advertisement