Windows I need help

Franco1227

Member
Hello, I'm creating a game for a game jam. But, I need help to solve a problem: I created peaceful enemies, you only kill them and get points. I duplicated them by pressing alt in the room editor. But, when I kill only one, I kill all of them. The deadline is short, so, if I need, I'll create one object for each clone. But I'd like a simpler method. See my code:
if (place_meeting(x,y,obj_enemy)){
global.kill = 1;}
else { global.kill = 0; }

if global.kill = 1 and keyboard_check(vk_space) {
instance_destroy(obj_enemy);}

(note: global.kill means the possibility of killing) PLS HELP ME
 
Remove obj_enemy from the instance destroy. That is destroying all objects called obj_enemy. Instead, store the instance ID of the enemy being hit and then destroy the instance ID (also, why do you need global.kill? It seems entirely redundant):
Code:
var _inst = instance_place(x,y,obj_enemy); // Store the instance ID in a local variable called _inst
if (instance_exists(_inst)) { // If _inst is holding a valid instance ID
   if (keyboard_check(vk_space)) { // And the user is pressing space
      instance_destroy(_inst); // Destroy _inst
   }
}
 
Top