Image above shows 2 same object next to each other.
When player grab, he grabs both which i dont want.
I want player to grab one by one even he is in collision area of both.
Need solution. Thanks
Try using an object variable for the player and the object to mark it if the player have had already grabbed an object and which object was grabbed
If player is in collision with object and grab it
If player grab = 0
Then grab object and set player grab = 1 and object grab = 1
This way, when the execution get to the second object, grab is not going to be = 0 and it should be not grabbed.
And to know which object to actually move to player check the variable
If object grab = 1 Then Do = X and Y to the position of object.
So this way only 1 object should move at the time, the one the player grabbed.
You can also try using object linking events instead of object variable.
No it don’t work… the player still grab both
Perhaps I can do something like. If player collide one object only…
If the 2 same object are behind at each other…
Situation : there 2 object1 in the scene and behind one another
Player collision object1 and one object1 only → proceed.
Not sure how can I make this to work
For now I’m adding fusrodah ability to player to push the object so they will separate with separate event
Need to use the for each object event because it seems the collision checking return and array of all objects involved in the collision and apply the action on all of them at once.
Using object linking event solve this and no need the for each event to grab the object but then when I was trying to check if there is any object linked to the player by reversing the condition it did not worked and I had no way to know if the player have grabbed something or not.
So I ended up using variables to flag if the player grabbed something and which box was grabbed. Not nice but works.
If you need one, you can download the example from here (grab-drop-object):
//EDIT: I have upload an example using links, it is much cleaner
aren’t that means that you have 2 different object. I beliv the object dont change name , just added label in the debugger
hmm perhaps , grab = 1 and update text if grab == 1: then its grabbed. if thats what you mean by not nice XD.
No, I have 2 instance of the same object and I’ve been using in the first example an object variable to flag which one was grabbed and in the second example with link I was simply link the instance to the player.
Yeah, in the example with links I ended up using a variable to check if the player grabbed something or not.
At first I tried to check if any box is linked to the player then it means the player have had grabbed an object but for some unknowns reasons the condition did not work in this scenario. So I’ve been using a var yes.