• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Collision event not triggering

Bentley

Member
I am making a Space Invaders base, and the base has a sprite that is drawn to a surface, and the surface is drawn at the base's x/y (the draw event overrides the normal drawing of the sprite). But the base does have the sprite assigned to it, and it therefore has a collision mask. The problem is that I can't get the collision event to trigger between the base and a laser, yet I can detect a collision using a place_meeting check. Does anyone know why the collision event does not trigger? (The code is changed when I test it in the collision event. For example, other is used to get the id of the laser instance.)
GML:
if (place_meeting(x, y, o_laser))
{
    var laser = instance_place(x, y, o_laser);
    var dx = laser.x - x;
    var dy = laser.y - y;
    if (surface_getpixel(surf, dx, dy) > 0) // If the laser hits the base
    {
        surface_set_target(surf);
        gpu_set_blendmode(bm_subtract);
        draw_sprite_ext(laser.sprite_index, 0, dx, dy, 1, 1, 0, c_black, 1);
        gpu_set_blendmode(bm_normal);
        surface_reset_target();
        instance_destroy(laser);
    }
}
Thanks for reading.
 
Last edited:

Bentley

Member
@jobjorgos Hey Jobjorgos. It's a regular draw event. Also, the base does have a normal collision box at its position. I checked by drawing its bounding box (draw_rectangle(bbox_left...)) and it is as it should be.
@rytan451 Hey rytan. Yes, when I swap the code in the collision event I use other. The collision event does not fire. A show_message("Hello") will not work on the first line.

It might just be that I renamed a resource or something like that and there was some glitch. That's happened before. It's not a big deal either way, was just wondering if I missed something obvious. Thanks for the replies. I'll mark this solved.
 
Last edited:
Top