Forum Discussion
Drag and Drop Issue - How to disable drop targets
I am creating a fraction game where the player is dealt a card and can choose where to place the card. I disable the card once it is dropped because the player is not suppose to move the card after placing it. That all works fine. The issue is that the player can now drop another card on top of the first one and replace it, but I do not want that to happen. How can I disable the drop target once a card has been dropped on it. I've tried using triggers, but that hasn't worked either. I've attached my file. Any help would be appreciated.
- RockyLittle-e27Community Member
For those of you having trouble understanding how to best support this look no further than Matthew Bibby's note ... you HAVE to put the shape on a separate layer ... then trigger that layer to "show" once the object has been dropped ... you'll need to ensure the objects from the base-layer are not set to hidden (do this in the gear icon menu when you are in "x" layer ... this will ensure the shape goes on top of the dropped object which will in turn; prevent the user from moving the tile .... you'll need a layer for each drop target
- GillianDelvigneCommunity Member
I found a band-aid solution which is :
1) Create a "deleted" state for your drop target and you delete the element from the scene in this state.
2) tell your drop target to switch to deleted state when your correct item is dropped inside. So your drop target will no longer display and would be disabled.
3) If your drop target had a specific shape you can tell by a trigger to display a fake drop target instead of the active one when the other one switch to deleted state.
It need more work, but in my case it is less tedious to set up.
Hope this will help you too.
- WillIllingworthCommunity Member
You know when you spend too many hours trying to figure something out by yourself?
And it just drives you more and more insane?
So you plead with yourself...
Then you read Gillian's reply.And your problems are solved.
Thank you Gillian.
🍻
- KevinBranaghan-Community Member
Gillian, I have 3 possible drag items that are all considered correct (just can't have more than 1 in each target. How do I go about disabling the drop target if any of the 3 possible items are dropped?
- JCBlanchardCommunity Member
What do you mean by "Deleted" state? Do you mean Disabled?
- JasonKramerCommunity Member
JC,
I tried the "deleted" state approach and it worked. By "deleted", is just a custom state where the actual object that was setup as the target_object is literally deleted, such that there are no actual objects in that state.
- GillianDelvigneCommunity Member
I have exactly the same issue. (See attachment)
I can't disable drop targets.I have two sides, 7 objects and 7 drop targets.
4 objects must go on the left side, no matter in which drop target. 3 objects must go on the right side, no matter in which drop target.
When I place an object in a valid drop target, the object is disabled and it is no longer possible to redrag it. When I place a bad item over it, it takes the place of my disabled object and the first one returns to its original position but remains in the disabled state. Which I don't want.I would like the drop target to be disabled when a good object is placed in it, so that it cannot receive other objects.
Given the number of possibilities per drop target, if I use layers to replace each filled drop target, I have to create images for each possibility, which makes me a large number of images and layers (4 images per drop target on the left = 16 + 3 images per drop target on the right = 9).
Any ideas?
EDIT :
Even if I "hide" my drop target and replace it by another image, the drop target is still active.
- BenMcKenna-ba88Community Member
You could try animating the drop target off screen using a motion path and setting it to 0.1s so it occurs almost immediately. I have no idea if the drag object would move with it, but I highly doubt it would.
- DeanLodes-a0bc2Community Member
Thanks Matthew. That is not a bad work around. I did try it, but even with the shape over the drop target, the new card replaces the old one.