Archived

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

Collision Response with "Boost" ?

This topic is 5108 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, My moving objects have a "cruise speed" and sometimes a "boost", the cruise speed is what makes the object go (kind of like a ball in Pong) and sometimes when it hits something I give it a boost. The boost runs out as time elapses so the object returns to it''s cruise speed. So when I have a collision the velocity at that moment is the cruise speed plus the boost (boost is always the same direction as the cruise speed.) I''m treating the objects like particles. I can find the new velocities after they hit but I don''t know how to break it up into cruise speed and boost, or even if that''s logical. I guess I can do two calculations, one for each: a collision response based on cruise speed only and another based on boost only, is that logical ? Or maybe I should just keep the old boosts and only change the cruise speeds after the collision ? What do you think ?

Share this post


Link to post
Share on other sites
Not entirely sure what you''re doing, but from a physics simulation standpoint, an object really only has a single velocity at any one time. The fact that that velocity is composed of or is the result of ''cruise speed'' and ''boost'' is of no concern to the simulator.

So I guess I would say that it''s not logical to try and break up the collision response into these separate components. Although I do admit that I''m not exactly sure what you''re doing, so I may be missing something obvious...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''m not sure what''s your exact problem but my first guess is that you should stick to the real physics for your collision with m1*v1 = m2*v2, the "boost" factor is there, there''s only one velocity and it contains everything about boost or cruise or whatever. Add friction to decrease the velocity with time (it''s a force -> change the acceleration then use an integration scheme like Euler...)

Share this post


Link to post
Share on other sites
the boost should provide an acceleration, and not change the velocity directly.

if (fTimeLeftForBoost > 0.0f)
{
Ship.AddForce(Ship.GetDir() * (Ship.GetMass() * fBoostAccel);
fTimeLeftForBoost -= dt;
}
else
{
fTimeLeftForBoost = 0.0f;
}

Ship.Update(dt);
//....
//....

Share this post


Link to post
Share on other sites
Hi guys,

Thanks for the help. I figured out a good way to do it. I have asteroids moving around space at a constant velocity but you can give them a boost if you shoot them in the rear, after a little bit of time they should slow down to their original speed. The problem was that if it had boost and hit another asteroid the asteroid that got hit would go really fast and maybe even hit another one causing a chain reaction. So I set a max speed and also set a target speed so they eventually slow down to their original speed. It works like a charm :o)

Share this post


Link to post
Share on other sites