Drag And Drop How to get the X and Y coordinates of a specific instance?


Wen Shan

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

Spencer S

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.