Vrtk: Snap Drop Zone Locked Out State

Created on 24 Mar 2017  路  12Comments  路  Source: ExtendRealityLtd/VRTK

There's an odd broken state the snap zones can get into where they can no longer snap new objects into them. The issue happens based on highlighting of the zone itself. Highlighting of a snapzone happens from OnTriggerEnter() and OnTriggerExit() calling ToggleHighlight(Collider collider, bool state). The problem lies in the fact that the ValidSnapObject() function checks to see if an object is grabbed. That makes sense for highlighting of an object, but not as much for turning it off. If the holding object is forced out of a grab and moved by an external force before it can be placed (destroyed, shot out of hand, blows up, manually removed, etc.), ToggleHighlight will not pass ValidSnapObject and thus, will not deactivate the highlight and will not allow any other objects to be snapped there because currentValidSnapObject is never cleared out.

I solved it locally like this, but it's a hack at best:

        private void ToggleHighlight(Collider collider, bool state)
        {
            var ioCheck = ValidSnapObject(collider.gameObject, true);

            // E7_MAB we don't care about grabbing state on unhighlight
            if (state == false && ioCheck == null) {
                ioCheck = ValidSnapObject(collider.gameObject, false);
            }

            if (highlightObject && ioCheck)
            {

GitHub version of VRTK, maybe a month old, not sure
Unity 5.4.3

bug waiting for feedback

Most helpful comment

Attached is a script to repro this issue in example 41.

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

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

  3. Script will force the ball back before a snap can happen.

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

The above code change allows the Unhighlight function in the snap zone to set it back into a usable state since it see the object leave the trigger.

image

InvalidSnap.zip

All 12 comments

_There is a "similar" error. If the object enters more than one trigger-Zones ofSnapDropZone's then this will happen everytime when i release the object in a free SnapDropZone. I use 4 nearby SnapDropZone's when i put a object in one SnapDropZone a other SnapDropZone next to first will be invisible even if it is still free. Of course I want to stay visible._

Error fixed

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

I'm not sure I follow what the issue is here, or if there are different issues.

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

Thanks for the info to make an update. My mentioned bug is fixed. But I noticed now:

  • when i grab an (snapped) item from a SnapDropZone and this Item leave immediately the SnapDropZone whitout to trigger the SnapDropZone trigger, than the SnapDropZone-Highlight still be invisible.

@Proktologe you have to provide steps to reproduce in an example scene for any issue otherwise people cannot see what the issue is for themselves and attempt to fix it.

I'll make a test in the example scene to show the issues. I'll submit some videos as well showing how it's breaking on me.

Here's a video showing what I do to lock out the snap drop zone. A zone is highlighted and upon release, since it's not a valid piece it's snapped back to it's original location and the snap drop zone becomes broken, no longer accepting any objects. The above code fixes the problem.

snapbackbug

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

@mattboy64 Hey Matt,

Are you still having the same problem? Im trying to destroy a game object that is being held in a snapdropzone and getting similar results. Once the gameobject is destroyed inside the snapdropzone, the snapdropszone becomes unusuable.

Any ideas?

thanks,
tom

@telso2 no, the above addition fixes the problem. I need to get @thestonefox some scripts to repro it himself and verify the fix should go into the mainline, but I've been pretty busy. I'll try and do that tonight.

Attached is a script to repro this issue in example 41.

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

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

  3. Script will force the ball back before a snap can happen.

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

The above code change allows the Unhighlight function in the snap zone to set it back into a usable state since it see the object leave the trigger.

image

InvalidSnap.zip

@telso2 actually I think your problem is really similar to the one in #1052. I added a script to test your problem in there. It's probably a similar fix, but might require a little more since I don't know what state it'll be in since it's being destroyed and all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wheatgrinder picture wheatgrinder  路  7Comments

ajaxlex picture ajaxlex  路  8Comments

thestonefox picture thestonefox  路  5Comments

broehl picture broehl  路  8Comments

dotcommer picture dotcommer  路  5Comments