Deprecated: Function get_magic_quotes_runtime() is deprecated in /home/public/forums/include/common.php on line 79

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/public/forums/include/common.php on line 83
To each instance his own. / GML Code Help / GMLscripts.com

GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

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

Rick_Bunker
Member
Registered: 2021-09-01
Posts: 1

To each instance his own.

Hi,

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 !

Offline

Board footer

Powered by FluxBB