GameMaker Other and instances?

Neptune

Member
Is this a correct use of 'other'?
Code:
partner_inst = instance_position(x,y,other);
In that partner_inst will obtain an instance-ID of the calling instance's object_index that is NOT its own ID (if one exists at that spot)?

Any info is appreciated!
 
Last edited:
No. "other" only works in a collision event or within a "with" statement. It doesn't magically grab some somehow-related index based on other assumed factors when used. Its purpose is to hold the id of a relevant instance depending on its usage.
 

Neptune

Member
Thanks for reply. Hmmm, now im not convinced one way or another.
I'll check back tomorrow and see what's actually happening, or note where I'm going wrong in my thinking xD
 
"other" just refers to a specific instance id during a particular action. If you use "with", it's the calling instance. If you use a collision event, it's the instance being collided with. That's it. You can't just throw it into a function and expect it will somehow work with object and instance ids to do flip-flop actions, or whatever it is you're hoping it would do.

If you want a different id of the same object index but at the same coordinates, depending on what exactly you need from the system, it can be as simple as:

Code:
x -= 10000;

var _temp = instance_position(x+10000,y,object_index);

partner_id =  (_temp != id) ? _temp : noone;

x += 10000;
 

FrostyCat

Redemption Seeker
other has a definite behaviour only in these two situations:
  • Inside an actual collision event (i.e. the ones from the event selector, NOT collision checks in the Step event or the like), where it refers to the colliding instance.
  • Inside a with statement, where it refers back to the originating instance.
Every other attempt to use other is wrong. The way you demonstrated is wrong, unless the line is in one of the two contexts listed above.
 

Yal

šŸ§ *penguin noises*
GMC Elder
Frosty already covered the what about other, but I think the why would help your understanding. other is a special value that resolves to the other object in a with loop or collision value, and is meaningless in any other context. Most notably, it is not an ID. You often want to store an object ID in a collision for later (e.g. when an object temporarily sticks to another) and it's important to use other.id instead of just "other" to get this reference right.
 

Neptune

Member
Ok, I don't use collision events, and I use 'other' and 'with' together often, but otherwise I don't need it.
The one case where I thought it might be useful is when you have instances of the same object pancaked together... And you're wanting to scrutinize the "others" and not calling instance.

Code:
instance_place_list
is the solution I normally use for this, but it's just more tedious.

I had hoped 'other', when used in replacement of an object_index in functions like 'position_meeting', might do what I wanted, that is all.
 

Joe Ellis

Member
In the case of position_meeting, in the manual it says you can use "other" to check for, but it's for when you have moved the 2 instances involved in the collision event, and you want to check if they're still in collision.
 
Top