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 have two bodies: one green static sensor (spikes) and one orange dynamic body (brick).

I have bullet and it's a dynamic body too, but with bullet flag set.

My problem is that when the bullet is moving left to right, it sometimes hits the orange brick instead of the spikes and it flies away. There is code to remove the bullet when it hits spikes. How can I make sure it hits the spikes first?

enter image description here

share|improve this question
add comment

closed as too localized by Byte56, bummzack, Josh Petrie, Anko, John McDonald Apr 17 '13 at 20:10

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

It might caused by the "high speed". Remember, most of the in-game movements are not continuous like in real life. The bullet might be fast enough to just pass your spike layer in one frame.

It can be pretty tricky to solve this problem... Please check this: Continuous Physics Engine's Collision Detection Techniques

share|improve this answer
add comment

You will need to set the moving body's definition as a bullet body. Are you still having the problem of skipping the sensor? If so, adjust the scale of the world or frequency of the simulation.

share|improve this answer
add comment

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