ultraleap / UnityPlugin

Ultraleap SDK for Unity.
https://docs.ultraleap.com/unity-api/
Apache License 2.0
531 stars 168 forks source link

Physics.ClosestPoint error with ARPlane and ARMesh in Unity using Ultraleap Plugin 7.1.0 #1656

Closed tichise closed 3 weeks ago

tichise commented 2 months ago

Description

I am using the Ultraleap Plugin 7.1.0 in Unity with the LeapServiceProvider in DesktopMode. I have added Physical Hands Manager to my scene, and I am generating AR planes and meshes using ARFoundation. However, when attempting to interact with non-convex objects (such as ARPlane or ARMesh), I encounter the following error:

Physics.ClosestPoint can only be used with a BoxCollider, SphereCollider, CapsuleCollider and a convex MeshCollider.
UnityEngine.Collider:ClosestPoint (UnityEngine.Vector3)
Leap.PhysicalHands.ContactBone:UpdateObjectDistances (UnityEngine.Collider[],int) (at 

I tried adding the IgnorePhysicalHands component to ARPlane and ARMesh, but this did not resolve the issue. Additionally, I attempted to disable collision using layers, but this approach was also unsuccessful. Since ARPlanes and ARMeshes are dynamically generated and non-convex by nature, it is difficult to make them convex. This is because making them convex would affect other processes. This issue also has a significant impact on other behaviors in the scene.

It seems that the Physics.ClosestPoint method is being called on non-convex colliders, which is unsupported. Is there a recommended workaround for handling AR-generated planes and meshes when interacting with Physical Hands Manager?

Steps to Reproduce

  1. Add Physical Hands Manager to a Unity scene.
  2. Use ARFoundation to generate AR planes or AR meshes.
  3. Attempt interaction with non-convex AR objects using Physical Hands Manager.
  4. Observe the error in the console.

Expected Behavior

Physical Hands Manager should be able to interact with AR planes and meshes without causing the Physics.ClosestPoint error.

Actual Behavior

The error occurs when interacting with non-convex colliders, such as AR-generated planes or meshes, which aren't supported by the Physics.ClosestPoint method.

Environment

rorygames commented 1 month ago

Hey, this is unfortunately a Unity physics limitation and not something that can be fixed. Unity's physics system cannot handle non-convex meshes reliably (specifically when using non-kinematic rigidbodies), they essentially have no volume and the physics system can't calculate them.

My suggestion would be to do one of a few things:

Please note that I do not have any prior experience with AR foundation's workings, so cannot provide any support with it.

MattFiler commented 3 weeks ago

This error should be resolved by #1660