Archived

This topic is now archived and is closed to further replies.

resting question

This topic is 5599 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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??

Share on other sites
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.

Share on other sites
well but it wont work? y? becuz ya also have velocity around zero when the ball reaches it''s max height.

Share on other sites
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.

Share on other sites
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.

Share on other sites
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).

Share on other sites
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.

Share on other sites
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]

Share on other sites
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]

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633663
• Total Posts
3013232
×

Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!