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

enemy bullets not specific to enemy?

T

teamrocketboyz

Guest
hello all i have a bullet object that my enemy fires and upon the bullets creation i have this code.

Code:
direction = o_enemy.image_angle
speed = 20
image_angle = direction
(very basic i know)

the problem is that if i have 2 or more enemies on screen then all of the bullets show go in the direction of the 1st enemies bullet.

i want each enemy bullet to go towards the direction that he was facing. i know its an easy fix but i cant figure it out.

PS i really do need to get my head in the manual.
 

Alexx

Member
Because
Code:
o_enemy.image_angle
does affect all instances, that's how it works.

One approach is to create a variable that holds the id of the instance you create, each instance has a separate id. Then set variables using the stored id value:
Code:
en=instance_create(x,y,o_enemy);
en.direction=image_angle;
en.speed=20;
en.image_angle=direction;
That should do what you require, if you need any more help, just ask.
 
Top