Snap Drop Zone Self Removal
See original GitHub issueCurrently the only way to remove an object from a snap drop zone is by grabbing it by hand. Any situations where objects might remove themselves from a drop zone don’t properly clean themselves up and the objects are still tied to the drop zone. Instead of forcing the player to manage that themselves, it would be nice to check if the object left the trigger in a different way (destroyed, moved, etc.) and (if it’s not being grabbed) release it from the drop zone. I implemented it like this in VRTK_SnapDropZone.cs:
protected virtual void OnTriggerExit(Collider collider)
{
//if the current valid snapped object is the collider leaving the trigger then attempt to turn off the highlighter
if (currentValidSnapObject == collider.gameObject)
{
ToggleHighlight(collider, false);
}
// New stuff here. If the currently snapped object is moved away in a manner other than a grab remove it from the snap zone.
if (currentSnappedObject)
{
VRTK_InteractableObject interactableObject = ValidSnapObject(collider.gameObject, false);
if (interactableObject && currentSnappedObject == interactableObject.gameObject)
{
OnObjectUnsnappedFromDropZone(SetSnapDropZoneEvent(currentSnappedObject));
}
}
}
Unity 5.4.3 GitHub version from 3-4 weeks ago…maybe
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Snap Drop Zone Self Removal · Issue #1052
Currently the only way to remove an object from a snap drop zone is by grabbing it by hand. Any situations where objects...
Read more >Snap Drop Zone
Provides a predefined zone where a valid interactable object can be dropped and upon dropping it snaps to the set snap drop zone...
Read more >VR Snap Zones (using VRTK)
A Snap Zone (or "Snap Drop Zone") is a designated area where you can place an object near it, illuminating a shape to...
Read more >VRTK v3 - [Basics] Snap Drop Zones - YouTube
FOR VRTK V3 NOT VRTK V4 #VRTK Slack: http://chat.vrtk.io - http://invite.vrtk.io A tutorial on how to use the snap drop zones to place ......
Read more >Create drop zones in Motion
Open the Image Inspector and click the Drop Zone checkbox. The drop zone parameters appear. To replace the original image with a drop...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right, right. You’ll need some additional functionality on the interactableObjects, but I’ll just pass you some quick scripts to mimic what I’m doing (roughly) in the above animations. Namely to automatically snap back to a position on release, and another to move itself out of a snap drop zone. It should be pretty easy to repro though.
Attached is a script to repro this issue in example 41. The problem can be seen if the object removes itself or is destroyed in a snap zone.
Object Moves Itself Steps
Attach the Move.cs component to the red ball.
Place the red ball in the far left snap zone.
Wait 3 seconds.
The ball will move itself outside of the drop zone.
Observe that no other object can be placed in the spot.
Object Deletes Itself Steps
Attach the DeleteSelf.cs component to the red ball.
Place the red ball in the far left snap zone.
Wait 3 seconds.
The ball will destroy itself.
Observe that no other object can be placed in the spot.
The above code change allows the Snap drop zone to remove objects that are no longer in the trigger zone. I’m not sure the code fixes the deleted state, but added a script to test that for @telso2 since I believe it’s the same problem.
MoveAndDeleteScripts.zip