Pickable Objects
Let’s add some objects in the scene
1. Go to Assests->SteamVR->InteractionSystem->Samples->Prefabs
2. Drag both ThrowableBall and ThrowableCube in the Hierarchy and move them in the Teleporation Area.
Also, make sure the Y axis is above the floor.
3. The last thing we need to do here is create a mesh Collider for our floor.
4. Select the MainFloor object, go to the Inspector tab.
5. Click Add Component, search for Mesh Collider, and check the Convex box.
6. TEST! You should now be able to pick up the objects you added and throw them around.
OPTIONAL: You can play around with the weight of the objects by selecting the children (Sphere/Cube) and tweeking the Rigidbody->Mass property. The higher the mass, the heavier the objects. This will be reflected on pickup.
Now let’s create our own objects to pick up.
7. Right-click anywhere in the Hierarchy -> 3D Object -> Cube
8. Name it MyCoolCube and place it somewhere above the MainFloor, in the play area.
9. Click MyCoolCube and check the Inspector tab. Make sure it has a BoxCollider and a Rigidbody with Use Gravity checked.
10. Now, with MyCoolCube selected, drag the following scripts in the Inspector tab from Assets->SteamVR->InteractionSystem->Core->Scripts:
- VelocityEstimator
- Interactable
- Throwable
- InteractableHoverEvents
TEST! Now you can pick up + throw MyCoolCube. Isn’t that cool?
11. The last thing we want to do with MyCoolCube is making it Shine (appear as interactable) when we hover our controllers on it.
12. To do this, select the cube, and check the Ineractable Hover Events script in the Inspector tab.
13. Create a new On Hand Hover Begin item and choose: Runtime Only, MeshRenderer.material, MyCoolCube (mesh Renderer), ShinyWhiteHighlighted
14. Create a new On Hand Hover end item and choose: Runtime Only, MeshRenderer.material, MyCoolCube (mesh Renderer), ShinyWhite
OPTIONAL: Play around with the materials here to make cooler effects when hovering.
15. The last thing I want to do here is make the ball bouncy.
When you throw the ball you want it to bounce rather than slide on the floor.