Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p2 physics -> reset Collision? (improvement/suggestion) #1362

Closed
jppresents opened this issue Nov 24, 2014 · 1 comment
Closed

p2 physics -> reset Collision? (improvement/suggestion) #1362

jppresents opened this issue Nov 24, 2014 · 1 comment

Comments

@jppresents
Copy link

I ran into the following problem using the p2 physics:

I have a sprite that collides with everything (default state), now an event happens in the game where I want this sprite to temporarily not collide with anything. After a few seconds I want collision again.

To disable collision there is
sprite.body.clearCollision(true);

But to enable default collision again I have to do this:
sprite.body.data.shapes[0].collisionGroup = 1;
sprite.body.data.shapes[0].collisionMask = 1;

(This works fine, assuming the sprite only has one shape.)

I would like a function, that resets collision to the initial state (the state which objects have right after setting them up with p2 physics and a shape) because I don't like to "internal" properties"set it to "magic numbers".

Is the solution maybe to implement a function on the p2 body like "resetCollision" that iterates the shapes and sets collisionGroup & collisionMask to 1?

Thanks

@photonstorm
Copy link
Collaborator

This feature request has been moved to the Phaser 3 feature list (so is being closed here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants