You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: