NOTE: I know this is a repost of for another topic, but I find this tutorial valuable and don't want this tutorial to get overshadowed.
The map page for reference will be: https://www.plazmaburst2.com/level_edit ... -detectgun
First, we record the coordinates of the gun constantly.
This is achieved by moving the region to the gun and getting X and Y coordinates of that region.
Next, we check if the coordinates of the gun is within the bounds of the coordinates of the collector.
Imagine this area is the collector. It has 4 sides. The gun can only be in the collector if:
1. X coordinate of gun > left limit
2. X coordinate of gun < right limit
3. Y coordinate of gun > bottom limit
4. Y coordinate of gun < top limit
If these 4 conditions are fulfilled, then the gun is definitely in the collector.
NOTE 1 - In the PB2 ALE, the lower the object, the Y value increases. Therefore, to compare the coordinates with the bottom and top limit, we have to flip the sign. Therefore, step 3 and 4 should be:
3. Y coordinate of gun < bottom limit (smaller means the gun is higher in Y axis.)
4. Y coordinate of gun > top limit (greater means the gun is lower in Y axis.)
NOTE 2 - This detects only the location of the gun, so if the player is holding on to the gun and enters the collector, the trigger will still be executed. To tackle this solution, one of the method is to make the area unaccessible for players, perhaps with a tiny gap. Another way is to check if the gun is equipped by anybody, but this method can get complicated as well.
NOTE 3 - Depending of your decoration offset, if your decoration is offset-ed far away from the gun, the detection may not be smooth. This is because the detection detects the gun, not the box decoration. There is currently no way to solve this, as regions cannot be moved to decorations.
NOTE 4 - To reuse the trigger, activate the infinite calling timer again.
Best regards,
Nyove