(Solved) Grab and Drop Object

My grab and drop works but heres what happens when I grab 1 object

All (the same) objects are affected and goes to my character position. I want to grab each object individually. Anyone has any idea how to do this?

here is my work:

I think you need a Boolean variable on the object being carried so only that one gets picked and moved. Something like IsBeingCarried. You can use the current Boolean to prevent more than 1 object from being picked up. If you desire to.

Collision with object
Set object Boolean to true

If object Boolean is true
Move object

I’m not sure if I’m doing it right.

All the copies of the object still goes to my character pos

The last event isn’t checking for the object variable. So all of the objects are being moved. Add the object variable condition.

Screenshot_20240710_194712_Samsung Internet

Try making the above conditions check for each object using the ‘for each object’ event.

I can’t use Gdevelop now so here is a link for the documentation of this event:


Thank you for this @v9um!

This worked! Thank you so much @Keith_1357 . Now, I just discovered a new issue lol. When the object is being carried and when I collide with another object it joins and is carried as well :sob: How do I make only one object is carried at a time.

1 Like

Use your other variable with the pickup event

IsHolding is false

Set beingCarried to true
Set IsHolding to true

Edit: It worked! Thanks!

And I just discovered yet again another issue hahahah I was trying to fix this but I’m not getting any good result. So, What happened was when both object is nearby, both objects are grabbed by the character. Is there a way to make the character only grab a one even though both objects are near?

You can use the pick nearest object for the object that gets picked up after the collision. You can use the player X, Y for the location. That will pick the closest of any objects that are in collision.

I put the condition here

It picks up on the nearest object, but when I release the button the other nearest object kind of like teleports to wherever I drop my object.

Put the pick nearest object in the event that has the collision after the collision condition but inside the same event so it picks the nearest that’s collides with the player.

When you drop it you might need to choose a location away from the player or use some other method, so the object doesn’t immediately collide with the player and get picked up again.

1 Like

Thank you so much for this, it works as intended now. :heart:

1 Like

You’re welcome. Good luck going forward.