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

GML Visual How to get the X and Y coordinates of a specific instance?

W

Wen Shan

Guest
In my game it has several obj_enemy instances. There is another object called obj_vision that is supposed to follow the enemy around. There is one obj_vision per obj_enemy. I cannot do jump to obj_enemy.x/y per step because that would cause all the obj_visions to go to 1 obj_enemy. So I gave all the obj_enemy and obj_vision instance names like inst_V1 inst_V2... for obj_vision and inst_E1 inst_E2... for obj_enemy I am trying to say that if the instance id is inst_V1 then it would jump to inst_E1.x/y per step and so on for inst_V2 and inst_V3 and so on. However it's not working.gms1.JPG gms2.JPG
 
S

Spencer S

Guest
Just assign each obj_vision an "owner" variable, and set that variable equal to the enemy's ID that they should be following. Then, in the step event, set the obj_vision x and y equal to the owner.x and owner.y.
 
Top