Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to get an understanding for the Box2D/Farseer physics engine by implementing a small air hockey simulation. There, I have the problem that the CPU player attacks the puck, kicks it, but also gets kicked back due to restitution. I would like the CPU player's mallet to be pinned to where it currently is; being able to kick others, but not getting kicked by something else.

I have tried setting its restitution to 0 but restitution is always the maximum of the two colliding bodies and as the puck has a restitution of 0.9, the mallet will also move.

I have also tried changing the mass of the mallet to a insanely high value but this influences damping again.

What is the best approach to really pin it afte collision?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I have tried setting its restitution to 0 but restitution is always the maximum of the two colliding bodies and as the puck has a restitution of 0.9, the mallet will also move.

I thought you came to conclusion that this was not true in the comment in another question?

Anyways the only thing I can think of is to use a sensor.

On BeginContact disable the body and set the Body.Position manually to a location beside the mallet. To pass/shoot I would sets its velocity in what ever direction and then re-enable the puck after its a certain radius distance from the player.

share|improve this answer
    
Yeah, I seem to have been wrong about the restitution. It really is using the max. Your idea brought me to the following solution: I added a collision handler. If it collides with the puck, the LinearVelocity is set to 0. This prevents bouncing and stops the mallet. Thanks for the hint with the velocity. –  Krumelur Feb 17 '12 at 21:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.