• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

SOLVED Problem with multiple instances changing a single variable


Hi. I have no idea if I missed a point of something, but this is leaving me completely speechless.

I have this object that is supposed to be picked up by a player. After getting player into certain range it should set a variable to 1, indication that it is in a pickable range. If player is in this range you can press a button to pick it up. Everything is working as it should except that variable.

Problem I have is that only the newest instance of that object is changing that variable. The older ones can still be correctly picked up, but it will not change that variable.


if collision_circle(self.x,self.y,collisionSize ,obj_player,false,false)
objDrawInteractGUI.showPickup = 1;
if gamepad_button_check_pressed(0, gp_face1)
if keyboard_check(ord("Q"))
objDrawInteractGUI.showPickup = 0;

If I use a collision event istead for changing the variable it works and every single instance of that object will be able to change it.

Why its not working in a step event? Am I missing something?
Last edited:


Friendly Tyrant
Forum Staff
By using the point method to target an object you are effectively asking gamemaker to choose which one to target, as that won't target all of them. This is usually the last one created, hence your issue (but it might not always be!). Instead use "with".

with (objDrawInteractGUI)
showPickup = 1;
Something like that...


Remove the "else" condition. Have objDrawInteractGUI reset showPickup to 0 in itsBegin Step event.
Thank you.

Not only for a fix, but also steering me to the right direction. As Nocturne suggested, I also had my mind suck on the idea, that if it could be fixed with "with" statement. But now i finaly see the problem, that the last instace of that object was always determining/overwriting the showPickup value.

I feel kind of stupid right now.