S
Someone
Guest
I made Space Rocks in GML and added a Collision event with other asteroids that makes both of the objects change direction:
But when I hit them with my bullets they are glitching. I tried to add the variable
to the asteroid's create event and in the User event that fragments the asteroids and destroys them I added 1 to the variable
and sent an alarm to reset the variable to 0. Then I added a condition to the collision with other asteroids that makes it only run when the variable is equal to 0:
This didn't work and I really need to solve this problem before going on. Thank you so much in anticipation
GML:
direction += 180;
GML:
collisionInvulnerability = 0;
GML:
instance_destroy();
score += 10;
repeat(irandom_range(6,10)){
instance_create_layer(x, y, "Instances", obj_debris);
}
if(sprite_index == spr_asteroid_big){
repeat(2){
var newAsteroid = instance_create_layer(x, y, "Instances", obj_asteroid);
newAsteroid.sprite_index = spr_asteroid_med;
}
}
else if(sprite_index == spr_asteroid_med){
repeat(2){
var newAsteroid = instance_create_layer(x, y, "Instances", obj_asteroid);
newAsteroid.sprite_index = spr_asteroid_small;
}
}
alarm[0] = 5*room_speed;
audio_play_sound(snd_hurt, 1, false);
collisionInvulnerabilty += 1;
GML:
if(!collisionInvulnerabilty == 0) exit;
direction += 180;
Last edited by a moderator: