Possible to disable col response on intersecting objects?

andrewaah
Posts: 6
Joined: Tue Sep 25, 2007 1:56 pm

Possible to disable col response on intersecting objects?

Post by andrewaah »

When I fire a bullet or missile it is created at the ships origin.

The problem is as I've set my groups so bullets and missiles are able to collide with any ship, the ship registers a collision with its own bullet or missile when it shoots.

So it is possible to make it when objects are already intersecting that there be no collision response and no callback from the 'defaultNearCallback'?

Thanks.
hiker
Posts: 83
Joined: Tue Oct 24, 2006 11:52 pm
Location: Australia

Re: Possible to disable col response on intersecting objects?

Post by hiker »

HI,
When I fire a bullet or missile it is created at the ships origin.
Why don't you simply add an offset to the location of the ship's origin (properly rotated by the rotation of the ship of course) to get the start location of the rocket? This way the rocket will not hit your own ship (assuming that the missile is faster than the ship :) ). The offset would be roughly half the length of the ship plus half the length of the rocket plus a certain epsilon to avoid a collision with the rocket being too close in the first time step.

After all, you want a ship to be able to be hit by its own rocket (consider a kind of homing missile which might turn around and come back :) ). I am using this approach in SuperTuxKart, and it works fine.

If this should be graphically not acceptable (since the rocket would suddenly appear ahead of your ship), perhaps you could display only the graphics at the first few timesteps, and actually create the rigid body once the rocket is far enough from he ship (though then you would have to do some simple physics yourself - for one type of rocket I am using a kinematic body which I have to move myself, it can be as easy as new_position=old_position+rotation*velocity*dt)

Hth,
Joerg