• 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!

Destroy one instance of an object help

K

K3ks3

Guest
So, my problem is that i wanted to destroy for example a bullet that i created with my keyboard_check(mb_left) and if that bullet hits a wall it destroys itself
everything is fine
but if there are more than two bullets every bullet gets destroyed.

Bullet Step event
Code:
if (place_meeting(x , y, obj_wall_solid)) {
     instance_destroy(obj_projectile);
}

In the Create Event for reference:
   
    move_towards_point(mouse_x, mouse_y, bullet_speed);

// new code
var dir = point_direction(x, y, mouse_x, mouse_y);
    image_angle = dir;
    direction = dir;
Step Event player
Code:
//  only shoot five times
    if mouse_check_button(mb_left)  and (instance_number(obj_projectile) < 5) {
        instance_create(x, y, obj_projectile)         
};
I need help.
 

Blackmore

Member
instance_destroy(obj_projectile) would destroy any instance of that object. Try to use Instance_destroy(); instead.
 
C

CreatorAtNight

Guest
Replace
Code:
instance_destroy(obj_projectile);
with
Code:
instance_destroy();
Then it will only destroy itself, and not every instance of obj_projectile
 
K

K3ks3

Guest
Wow, Thank you for the quick response and yeah that helped, Thanks man. ^^
 
Top