Vrtk: Snap Drop Zone Self Removal

Created on 25 Mar 2017  路  13Comments  路  Source: ExtendRealityLtd/VRTK

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

bug waiting for feedback

Most helpful comment

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.

All 13 comments

Can you add clear steps to reproduce the issue in the example scene.

Also make sure to do this on the latest version of github master.

To show how this breaks on me, here's an example of a snapped object being removed from a slot in a manner other than by your hands. The captured piece is moved out of the slot, but the slot doesn't reset gracefully in this case and the snap drop zone no longer can be used by any other object (black doesn't use drop zones). The above code fixes this problem.

forceremovebug

@mattboy64 I need steps to reproduce the issue in an example scene otherwise I cannot see what the problem is first hand.

You need to try and recreate the issue using the existing example scene and provide text step by step instructions for me to follow.

@thestonefox right. I'll get you a scene based on the example ones sometime this week, I've just got to get ready for some major home renovations that are happening (starting in the morning) and at least wanted to give you a little context on why it's happening in my case. Thanks for everything, snap drop zones are awesome!

@mattboy64 don't build a separate scene with the issue. recreate the issue in the snap drop zone example scene then provide step by step instructions of how to recreate that issue in that example scene like:

 * First do this
 * Then do this
 * And then this

I expect this...

But I get this...

This way I can recreate it in my development version and see the problem first hand.

@mattboy64 here's a good example of an issue with clear steps to reproduce: https://github.com/thestonefox/VRTK/issues/958

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

  1. Attach the Move.cs component to the red ball.
  1. Place the red ball in the far left snap zone.

  2. Wait 3 seconds.

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

  4. 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.
  1. Place the red ball in the far left snap zone.

  2. Wait 3 seconds.

  3. The ball will destroy itself.

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

Thanks @mattboy64 I'll investigate today!

@mattboy64

Thanks matt! Tried both scripts and they work as you described. The move script indeed does remove the ball from the snap zone and lets you re-use the snapzone, but for some reason when the sphere is to be deleted( and its not snapped at all) it still renders the snap-zone unusable hmmm.

Tried a workaround by removing the snapzone altogether and instantiating a new one, but cant seem to get that to function properly either. I'll keep trying.

cheers,
tom

@telso2 to be clear, the issue with the move is that no other object can use that snap zone, it still thinks the first ball you place in it is still there. If you try placing the other ball or the cube in it after it removes itself, you'll see that it's in a stuck state.

@mattboy64 Yeah, you're correct. I thought maybe if I deleted it once it had been moved if would fix the issue, but no such luck.

Was this page helpful?
0 / 5 - 0 ratings