In the previous blog, we learned to set up hand tracking and also learned about grab interaction. In this blog, we’ll be talking about poke interaction. As the name suggests, we’ll see how to create a VR Button that can be pressed by poking.
Before we can start creating a VR button:
If you are not sure how that’s done feel free to check out the hand tracking setup blog.
Let’s see how we can create a VR Button from scratch
First, we’ll create a framework and later we’ll add the required components.
Now let’s create a button by creating a 3D object inside the Model GameObject.
To make the button work we’ll have to add some logic to it by adding the required components. What are those components? Let’s see.
We further enrich this interaction by adding audio or visual effects. For now, we’ll add audio effects, and to do that:
That’s it now you will be able to hear audio when the button gets completely pressed and also when released.
Initially, we created a framework for the button right? If you are thinking as to how we can make use of it to create different types of buttons, then the answer is really simple. We’ll have to just change the object that’s under the Model GameObject and make sure the object’s top surface matches with the Model’s transform. Now we’ll be able to create all kinds of buttons. In the next section we’ll see how to create ray interactable canvases.
If you've enjoyed the insights shared here, why not spread the word? Share the post with your friends and colleagues who might also find it valuable.
Your support means the world to us and helps us create more content you'll love.