resting question

Started by
7 comments, last by Agemaniac 20 years, 8 months ago
ok..i have a problem with physics in my game. i don''t know how to determine that a object is resting. for example.. a ball falling...it will hit the ground and bounce. ok..it will bounce..bounce...and it´s like infinite. so..how can i determine that the ball stop??
Advertisement
I''m assuming that everytime it bounces it loses a bit of velocity due to inelastic collisions and whatnot. Basically all you need to do is define a cutoff value for the velocity below which you just set it to zero.
well but it wont work? y? becuz ya also have velocity around zero when the ball reaches it''s max height.
quote:Original post by Persian_Gamer
well but it wont work? y? becuz ya also have velocity around zero when the ball reaches it''s max height.


So what? It won''t stop acceleration being applied to the object.
thks fo y post...ok..but if you still continue to aply the aceleration in the body it will go into the ground when you set the velocity to zero!!! if you aply a force in the body, to opose the gravity, when it reaches zero than it will stop when arrive in the max height.
I think Persian_Gamer is right. Even if you continue to apply force to the ball on the peak of it''s path, if the resulting velocity is too small it''ll be set to zero. And so the ball will stop when it reaches the peak.

You''d have to make sure that the resulting velocity when applying gravity for example is always greater then the cutoff (heavy object -> high inertia -> might not start moving).

The other problem of the ball not going through the ground can be solved by making your physics engine a bit more realistic. Simply make the ground apply a negative force to the object equal to the force of the object pushing ''into'' the ground.
Of course the amount of force the ground can apply to an object (in reality) is limited, and at some point the object will start digging into the ground (or if it''s a floor inside a building break through it). But for a game engine you could simply make it so the ground can withstand any object (= allow it to counteract any given force).
How do I set my laser printer on stun?
when you find a contact, calculate the force along the plane of contact. if the amount is < to a threshold, you can consider the object as resting.

Fnorm = F.Magnitude() - (F * N)

if (V.Magnitude() > 0.01f and Fnorm < 0.1f)
resting = false;
else
resting = true;

or something Haven''t implemented resting objects yet. However, that algo will not work nicely if an object is overhanging above another object. It''s quite complicated if you want to do it properly. What if the supporting object dissapear? The supported object should fall, but if it is resting, it won''t get updated, so it will stay in mid-air.

Everything is better with Metal.

Don't do a cutoff for upward velocity, only check the cutoff for downward velocity.

if((velocity[1] > -0.01) && (velocity[1] < 0))     velocity[1] = 0;  


[edited by - Stonicus on August 13, 2003 3:45:27 PM]
you still need to check for the velocity along the plane, and the plane normal separately.




resting_contact = true;

v_norm = V * N
v_plane = (V - N * v_norm).Magnitude()

if (v_norm > 0.01f || v_plane > 0.01f)
resting_contact = false;



f_norm = F * N
f_plane = (F - N * f_norm).Magnitude()

if (f_norm > 0.01f || f_plane > 0.01f)
resting_contact = false;

[edited by - oliii on August 13, 2003 6:54:43 PM]

Everything is better with Metal.

This topic is closed to new replies.

Advertisement