Discuss and collaborate on GML scripts

You are not logged in.

#1 2021-09-01 20:50:27

Registered: 2021-09-01
Posts: 1

To each instance his own.


I’m working on Game Maker studio 1 and I have a problem :

I have 10 instances of the objectA and 10 instances of the objectB and I want that each instance of the objectA choose his own nearest instance of the objectB and go after it. So I used this coding :

“var Aim, H, V
with (objectA)
Aim = instance_nearest (objectA.x, objectA.y, objectB)
H = Aim.x
V = Aim.y

And I make the objectA goes “Step Towards” to “x:H” and “y:V”. But all instances of the objectA goes always toward the same instance of the objectB, i.e. to the instance of the objectB nearest to only one of them.

Is it existing a solution to this problem or do must I create 10 different objects and paste 10 times the same code ?

Thanks in advance for you answers, I’m really stucked here !


Board footer

Powered by FluxBB