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 looking for a bullet that can collide with other bodies of the world but doesn't change direction according to collisions. I want the bullet to perform the collisions but without changing its own direction of moving. Basically I want to create a super bullet that can kill multiple bodies available in sequence. Would you have an advice?

If RayCastCallback is part of the solution, then could you tell me how to use it in this case?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

AndEngine's physics is based on Box2D. In Box2D , you can create the Body of your bullet with a sensor Fixture. There is a flag you can set on the FixtureDef to make it a sensor. A sensor in Box2D is basically a Fixture that will participate in collisions but not react to collisions on its own which is what you want. You can then provide custom responses to collisions by registering for some callbacks...

From Box2D User Manual:

Sensors do not generate contact points. There are two ways to get the state of a sensor:

  1. b2Contact::IsTouching
  2. b2ContactListener::BeginContact and EndContact

I'm sure those callbacks/flags are exposed in AndEngine somehow.

share|improve this answer
add comment

The usual way of creating bullets in video games is to perform raycasts, see this question for details. What you want is just a raycast that doesn't stop on the first intersection: there you go, undeviating bullets.

I've no experience with AndEngine so I can't tell you if RayCastCallback will do the trick, but that's possible.

share|improve this answer
add comment

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.