• 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!

GameMaker problems accessing variables of collided object

S

sabixi

Guest
I'm trying to access the y position of an object the player is colliding with, this code was me testing things, so I'm just trying to get the id of the collided object here:

if place_meeting(x, y+vspeed_, o_slope_r){
show_debug_message(other.id);
}

For some reason, "other" is the player object, rather than the object I am checking the collision with, but it still detects the collision and prints the message.

I can get the correct id using instance_place (I know I could then use the id to access the y position, but I want to know why this isn't working)

Thank you
 

NightFrost

Member
There's no context for other to work with, so it doesn't return what you expected. It works either inside with context, pointing to the instance that executed it, or in a collision event. Collision event, not Step event.
 
S

sabixi

Guest
There's no context for other to work with, so it doesn't return what you expected. It works either inside with context, pointing to the instance that executed it, or in a collision event. Collision event, not Step event.
oh, that makes sense, for some reason I was thinking that place meeting would create context for it.. just being dumb

thank you!
 
Top