My player keeps picking up more than one object

Hello i am making a game akin to portal flash, but with a gravity gun.
there is a slight problem with my code though, because the device is meant to pick only one object up at a time and disregard everything else, but i haven’t been able to find a fix yet. it just keeps on picking up 2 objects at a time. this is really hampering development and i would like a fix fast
sorry for if my english is bad, i am not a native english speaker

Hello and welcome!

In your events, when the boolean “isholding” is TRUE, even though you added pick the nearest object, you’re then changing it’s position and other object may become the nearest instead and gets picked up.

I did some modifications to your events and should work for you now.

Basically, when picking objects, (trigger once) pick the nearest object and change it’s boolean “held” to TRUE. Then only do the actions to the object with boolean “held” = TRUE.

Yup it works!
thank you alot

You’re welcome! glad I helped.

1 Like