physics – Cocos2dx+Chipmunk: Absolutely elastic collision between transferring our bodies

physics – Cocos2dx+Chipmunk: Absolutely elastic collision between transferring our bodies

[ad_1]

I am utilizing Cocos2dx and the inbuilt Chipmunk physics engine, and at present I’ve obtained my PhysicsBodys’ supplies arrange with:

Density=0
Restitution=1
Friction=0

with a view to get totally elastic collision, and maintain transferring our bodies transferring at a continuing pace. This works nice in the event that they collide towards a static factor, like a wall, not a lot in the event that they collide with different transferring objects.

I am transferring these our bodies by making use of an preliminary pressure:

Vec2 velocity = moveDirection.getNormalized()*moveSpeed - myPhysicsBody->getVelocity();
Vec2 newForce = myPhysicsBody->getMass()*velocity / deltaTime;
myPhysicsBody->applyForce(newForce);

So I am guessing that although their supplies would end in totally elastic collisions, the transferring objects each carry an affect pressure, this modifies the ensuing pressure into one with completely different magnitude? All these transferring our bodies have the identical mass.

At the moment I am manually catching the affect begin and manually producing the ensuing pressure in the precise directing, and utilizing the item’s pace to use it with the identical earlier magnitude, successfully overriding Chipmunk’s collision decision.

Is that this one of the simplest ways to do that, or can I configure my our bodies in a manner that permits Chipmunk collision decision to realize the identical impact? I am a bit rusty on my physics.. heh..

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply