- Home /
How to hit objects in VR
I am trying to build a pressable button in Unity using SteamVR. However, before I can do that I need to be able to hit objects with the controllers and make them move. Any ideas on how to push objects in VR?
Answer by Vicarian · Jul 31, 2018 at 07:56 PM
I ended up writing a script to create and embed capsule colliders in the fingers of the hands Oculus provided. They use a SkinnedMeshRenderer which sets itself up dynamically based on bones and such. Not sure exactly how it works on their end. With the ability to collide, you can detect how far the button or another object moved from its initial position to do something with. After you process the DoSomething(), reset the button (or object) to its original position.
Alright, that is helpful, thank you. But, I am trying to physically push objects in VR. I will worry about the button part later.
Right, attach a rigidbody to the capsules and make them kinematic. Ensure anything you want to move around also has a rigidbody, and let the physics system take over.