C
Curry
Guest
I'm creating a platformer game. I want the enemies to constantly shoot in the direction they're facing, but I'm having a problem: the direction of the enemy bullets are all in sync. (In other words, one of the enemies correctly shoots in whichever direction it is facing, but all the other enemies shoot in that same direction, regardless of the direction they're facing).
I think the reason for this is because 'obj_enemy' means all instances of obj_enemy, but I want individual instances of obj_enemy to shoot in their own directions. How can I fix this issue? Here's some of the code I'm using:
(obj_enemy step event)
//create bullets
instance_create_depth(x, y, 0, obj_bullet);
(obj_bullet step event)
//fire direction
if obj_enemy.image_xscale > 0 { //facing right
x += hsp; //bullet moves right
} else if obj_enemy.image_xscale < 0 { //facing left
x -= hsp; //bullet moves left
}
I think the reason for this is because 'obj_enemy' means all instances of obj_enemy, but I want individual instances of obj_enemy to shoot in their own directions. How can I fix this issue? Here's some of the code I'm using:
(obj_enemy step event)
//create bullets
instance_create_depth(x, y, 0, obj_bullet);
(obj_bullet step event)
//fire direction
if obj_enemy.image_xscale > 0 { //facing right
x += hsp; //bullet moves right
} else if obj_enemy.image_xscale < 0 { //facing left
x -= hsp; //bullet moves left
}