D
Daz@mbi
Guest
Is there an efficient or simple way to check if an object is no longer colliding with another object when using the collision event?
That works perfectly, thank youIf you still want to perform that check with the Collision Event then maybe you can do something like this (this is untested, but I believe the events happen in the expected order).
- On the Begin Step event set a variable (e.g. collision) to false;
- On the Collision Event set the variable to true;
- On the End Step event see if the variable is true, if it is then a collision occurred and you can perform the remaining logic.
if (place_meeting(x, y, obj_spike)) {
alarm[0] = 2;
}
It's important to not setting alarm to 1 in this case, as alarms generally triggers when it's equal to 0, so it may be set to 0 right before NEXT collision event in next frame, and will be executed every time before/after collision.You can use an alarm event as well. Set the alarm to a small number of steps this way in the Step event:
The alarm would keep on resetting to 2 as long as there is a collision. As soon as the collision ends, the alarm would start to count down and trigger the Alarm 0 event, producing a Collision End alternative, that is, Alarm 0.Code:if (place_meeting(x, y, obj_spike)) { alarm[0] = 2; }