ExtendRealityLtd / ExtendRealityLtd/Tilia.Interactions.SnapZone.Unity
Tightly packed snap zones can cause a snap to unsnap another one
- Dominant language
- C#
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Unity version: 6000.0.60f1
Snap zone package version: 2.4.8
Other information: multiplayer environment
I have a snap zone setup with some really small objects, and precision is key. As you can see, one of the snap zones are entirely within the other one. This plays fine, since they have rules set up, so only the relevant snap zone is activated.
However sometimes, when I snap one first, and then the second, the former snap zone gets unsnapped. I have tracked it down to this function:
https://github.com/ExtendRealityLtd/Tilia.Interactions.SnapZone.Unity/blob/d1c35f0b842994917f5cc13c2fee3bd8fe40518f/Runtime/SharedResources/Scripts/SnapZoneConfigurator.cs#L450
```
foreach (GameObject collidingWith in snappableInteractable.Configuration.ActiveCollisions.SubscribableElements)
{
SnapZoneActivator activatingZone = collidingWith.GetComponent();
if (activatingZone == null)
{
continue;
}
activatingZone.Facade.Unsnap();
break;
}
```
And it seems to make sense, because when I let go of the snapped object, there are indeed two SnapZoneActivators in the ActiveCollisions list, even if one of them is rejected by the rules.
Recreate:
In example scene 0044 - Snapping Interactables to a Fixed Location, move one snap zone inside of the other, and decrease its radius to 1. Now, when you snap the outer one first, and then the second one, the first object is pushed out.
Contributor guide
Research direction
Start with Runtime/SharedResources/Scripts/SnapZoneConfigurator.cs at the linked logic around line 450, then reproduce the issue in example scene 0044 with one snap zone inside another and radius 1. Inspect how ActiveCollisions and the snap-zone rules are handled when the second object is released. Done means snapping the inner zone no longer unsnaps the already valid outer-zone snap; verify the nested-zone scenario in the example scene.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100