Search code examples
c#visual-studiounity-game-enginecollision-detectionoculus

Unity movable Menu interface. Problem with collision detection


I assume this is pretty easy but I did not find a solution yet. I have a 3D environment for VR in Unity. I have a Canvas in Worldspace which you can grab and move around like a tablet. In order to be able to touch the buttons on the canvas, I added a sphere on the tip of the controller's finger as a detector with a sphere collider. To the buttons on the canvas I added rigidboys and a boxcollider. With a onCollisionEnter Event I handle if the button and the finger are colliding and execute the onclick.Invoke() function.

It is working, the problem is if I touch the buttons they start moving and float around in the environment. If I freeze their position they won't be moved if I drag the whole menu around. How could I solve this?

Using Unity 2019.4.19f1 with Oculus OVR Plugin.


Solution

  • Ok, I solved it with the idea of setting them to kinematic as JustARandomWibuuuu suggested. If someone might have the same problem.

    I've set both to kinematic and in Project Settings → Physics → Contacts Pair Mode I had to enable all contacts.