edgarpetrauskas
edgarpetrauskas

Reputation: 401

Checking collision on two bodies without interfering in physics (Box2D)

I'm currently developing a small puzzler game, where the point is to shoot a ball against two other balls in a way that all (3) stars are collected in their paths.

Here's an illustration, to get an idea:

Example

All the round bodies are dynamic bodies. Mass of the star bodies is set to 0. I'm using the Box2D ContactListener class to check on collisions. On begin of the contact I remove the body and the texture of the star. But it still seems to affect the projectile like its still hitting something. I know I'm doing something wrong but just can't figure out.

Am I using the right method? Or am I forgetting something? Thanks in Advance!

Upvotes: 0

Views: 609

Answers (2)

The Windwaker
The Windwaker

Reputation: 1054

That's it, sensors dont move on collision. All you have to do is to change your stars's fixture definition on creation.

StarFixtureDef.isSensor = YES;

Upvotes: 1

kaushik
kaushik

Reputation: 21

Try sensors in box 2D so that it will not collide with any object, but will accept events.

Upvotes: 2

Related Questions