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
sprite.collider, is the getter/setter for a sprite's collider type. Behind the scenes in p5play, changing a sprite's collider type requires removing its entire planck.js physics body, sprite.body, and recreating it with the new body type.
There's a problem with the current implementation. If a sprite's collider type is set to "none" after overlap detection was implemented, the sprite will not regain its overlap sensors. Hence the cb callback function will not run. But it should, since sprites can have sensors without having any colliders. Reverse the lines and it works, but it should work either way.
Solving this will be tricky because some games rely upon the current behavior.
Let's look at "Into the Mines" by Tezumi as an example. In this game breaking platforms get their collider type changed "none" (along with an image change to show the empty space) when they break, the platform's overlap sensor is also removed. This error prevents player.groundSensor.overlapping(breakingPlatforms) from returning true, which in this case is desirable.
When an overlapping check is performed, if a sprite being checked doesn't have overlap sensors, the sprite will automatically receive default sensors based on its collider shape. But if a group is being checked, p5play will only add default overlap sensors to a group if no sprites in the group have overlap sensors. So that's why the breakingPlatforms don't get their sensors re-added. But for consistency they should,
...because otherwise this would work if the sprite is in a group and the user is doing an overlap check on the group.
breakingPlatforms are added to a super group, called ground. I think the best solution is to just remove a broken platform from the ground group.
bp.collider="none";ground.remove(bp);
But the thing is the player.groundSensor.overlapping(ground) check still returns true. I think this is because removing the broken platform from the ground group doesn't cause an overlapped event between the player's groundSensor and the ground.
The text was updated successfully, but these errors were encountered:
quinton-ashley
changed the title
[bug] sprite.collider = "none" removes overlap sensors
[bug] sprite.collider = "none" should not remove overlap sensors
Oct 10, 2023
sprite.collider
, is the getter/setter for a sprite's collider type. Behind the scenes in p5play, changing a sprite's collider type requires removing its entire planck.js physics body,sprite.body
, and recreating it with the new body type.There's a problem with the current implementation. If a sprite's collider type is set to "none" after overlap detection was implemented, the sprite will not regain its overlap sensors. Hence the
cb
callback function will not run. But it should, since sprites can have sensors without having any colliders. Reverse the lines and it works, but it should work either way.Solving this will be tricky because some games rely upon the current behavior.
Let's look at "Into the Mines" by Tezumi as an example. In this game breaking platforms get their collider type changed "none" (along with an image change to show the empty space) when they break, the platform's overlap sensor is also removed. This error prevents
player.groundSensor.overlapping(breakingPlatforms)
from returning true, which in this case is desirable.When an
overlapping
check is performed, if a sprite being checked doesn't have overlap sensors, the sprite will automatically receive default sensors based on its collider shape. But if a group is being checked, p5play will only add default overlap sensors to a group if no sprites in the group have overlap sensors. So that's why the breakingPlatforms don't get their sensors re-added. But for consistency they should,...because otherwise this would work if the sprite is in a group and the user is doing an overlap check on the group.
But that wouldn't work if the user checks for overlaps in a for loop instead.
That could be solved by checking whether each platform
b
has a collider type of "none".That would also work in callback form.
The actual section of Tezumi's code where the overlap check occurs is in player.js.
breakingPlatforms
are added to a super group, calledground
. I think the best solution is to just remove a broken platform from the ground group.But the thing is the
player.groundSensor.overlapping(ground)
check still returns true. I think this is because removing the broken platform from the ground group doesn't cause an overlapped event between the player's groundSensor and the ground.The text was updated successfully, but these errors were encountered: