• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM (SOLVED) Collision with multiple objects

Hello there.

Basically, im making platformer and trying to make one-way platforms. GMS 1.4
Not gonna bother you with a whole thing, my actual question is:

You have two instances: instance A (player-object), two instances of B (wall\floor\celling objects)

Let's say you check if instance A collides with any of B (with instance_place(x, y+1, obj_floor))
And in reality, instance A touches both of them (for example, standing on them both).

And, of course, instance_place returns only one ID.

Can you, with some black magic, manually set, which one is gonna be returned?

For example, if in this case i want to get only ID of left object.

I know about (instance_place_list) but not sure if i can manage such list as i want to.

Can i get ID of instance_place(x, y+1, obj_floor) ignoring instance_place(x, y, obj_floor)?
 
Last edited:

TsukaYuriko

☄️
Forum Staff
Moderator
You can iterate through the list returned by instance_place_list and manually find the leftmost instance. Loop through it while keep track of the up until that point leftmost instance's ID in a variable every iteration. The leftmost instance's ID will be stored in that variable at the end of the loop.
 
Thank you very much!

Just tried that. Actual mechanic is a little more complicated than i explained (i dumbed it down for the sake of simplicity), but it actually worked!

(i just didnt wanted to use _list because fear of further complications, but should have started with that)
 
Top