GMS 2 Instances Don't Run Code

I've had two problems with creating instances.
1.) Animations don't play.
2.) The step event never executes.

I'm trying to recreate Missile Command for school, it's due in 12 hours, and I can't figure out how to get the missiles to destroy when they collide.

How I draw laser
Code:
if dropTarget == "true" {
    draw_set_colour(global.col_nuke); //set target color - TEMPORARY
//CREATE THE LASER NUKE
    instance_create_layer(dropTargetx, dropTargety, "layer_lasers", obj_target);
    time = time + delta_time / missileDefenseSpd; //start timer
    
    draw_set_colour(global.col_nuke); //set laser color
    instance_create_layer(dropx, dropy, "layer_lasers", obj_nuke); //Make missile
    draw_line(dropx, dropy, dropTargetx_lerp, dropTargety_lerp);
    draw_set_color(c_white);    //reset draw color
    
    if time >= 2 {
        time = 2;
        dropTarget = "false";
    }
}
How I am detecting collisions between missiles. (In Draw & Step of obj_nuke)
Code:
var _hit = collision_rectangle(x, y, x + 10, y + 10, obj_missile, false, false); //location and size of missile hitbox
with (_hit) {
    draw_text(40, 50, "HOLY HIT!!"); //TESTING MESSAGE ONLY
    instance_destroy();
    }
The problem is the boxes are recognizing collision, but they don't execute anything other than draw_text. I have the obj_nuke and obj_missile acting as heads for the lines. I would have expected at least obj_missile to destroy. Any solutions?
 

FrostyCat

Member
You need the not-me argument (last) in collision_rectangle() to be true so that the source counts only other instances and stops instance_destroy() from landing on itself. Alternatively, use instance_place().
 
Top