question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snap Drop Zone Self Removal

See original GitHub issue

Currently 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:closed
  • Created 6 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
mattboy64commented, Mar 27, 2017

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.

2reactions
mattboy64commented, Apr 14, 2017

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

  1. Attach the Move.cs component to the red ball.

  2. Place the red ball in the far left snap zone.

  3. Wait 3 seconds.

  4. The ball will move itself outside of the drop zone.

  5. Observe that no other object can be placed in the spot.

Object Deletes Itself Steps

  1. Attach the DeleteSelf.cs component to the red ball.

  2. Place the red ball in the far left snap zone.

  3. Wait 3 seconds.

  4. The ball will destroy itself.

  5. 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.

image

MoveAndDeleteScripts.zip

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found