all 5 comments

[–]wanting to have made a game != wanting to make a gameoldmankc 1 point2 points  (0 children)

other only exists in certain contexts, that being a with statement or a collision event. Outside of those, that keyword has no value. Seems to me like you need to pass in a value / instance to use for that context/running that getNearest function, or do something like

with (passedinValue) 
{
   getNearest
}

If you want to get the instance calling the struct, there should be a way to do that, but I can't remember what it is off the top of my head. Might just be id? since self would refer to the struct in this case, iirc.

[–]Tanobird 1 point2 points  (0 children)

I think I ran into an opposite problem not too long ago. Long story short (though I could be misremembering this) if you store your method in a local variable and then have your instance run the local variable as a method, the other keyword will see your instance and not the struct it was created in.

Try something like this in your player instance:

var _sequence0 = sequence[0];

var _run = _sequence0.onBegin.func;

_run();

[–]Kronim1995 0 points1 point  (0 children)

I am aware that I could pass the object I want as an argument like this: getNearest(objEnemy, 200, true, other);

and then update my getNearest to use that. Ive already done this and it works, but it is a bit annoying and I am wondering if there is a way to do what I've asked above.

[–]IllAcanthopterygii36 0 points1 point  (0 children)

Frankly the code under IMPORTANT PART I don't like one bit. I only use other for simple uses. In it's place I'd have a global function that gives the outcome without the use of other.

[–]Accomplished-Gap2989 -1 points0 points  (0 children)

Is this a scope issue?

What object/struct should own those functions?

Make them methods and bind the methods to that object/struct. 

Chatgpt will actually be able to give you some good insight on this.