Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Overview

This article describes how to take a bottle with a cap attached. And, make it so both the cap and the bottle can be grabbed and moved around separately then reattached. The bottle and the cap will also be using gravity physics.

We will do this using four premade Motive SDK features:

  • VR Attachable

  • VR Attachable Receiver

  • VR Grabbable

  • Fixed Joint

Bottle&Cap.mp4

Setup

For this example, we are starting with this relatively simple bottle and bottle cap prefab variant:

  1. Right-click on the bottle in the Hierarchy window

  2. Select Motive > Make Grabbable

  3. Right-click on the bottle again

  4. Select Motive > Make Attach Receiver

  5. Expand the bottle in the Hierarchy window and right-click on the bottle cap

  6. Select Motive > Make Grabbable

  7. Back on the bottle cap, right-click and select Motive > Joints > Add Fixed Joint

  8. On the bottle cap, right-click and select Motive > Make Attachable

  9. Finally, in the Inspector for the bottle cap, scroll to the bottom and select Add Component

  10. Type in Mesh Collider

  11. Select Mesh Collider when it appears

NOTE: If there is already a Mesh Collider on the cap, there is no need to add a second

Configuration

All the necessary components have been added. Now we will add grab anchors for both the cap as well as the bottle itself.

  1. Right-click on the bottle in the Hierarchy

  2. Select Create Empty

  3. Modify the Y Position value under the Transform component of the new empty object (Move it near the middle of the bottle lengthwise)

  4. Select the bottle and then open the VR Grabbable

  5. Drag your new empty object into the black box next to Grab Anchor that reads “None (Transform)”

  6. Do the same thing for the cap of the bottle. Right-click on the cap and select Create Empty again

  7. Modify the new empty objects Y Position value under Transforms so that it is somewhere near the center of the bottle cap

  8. Select the cap and once again, under VR Grabbable, drag the new empty object into the same Grab Anchor box

Now, we must configure all of the newly attached components to replicate the behaviours shown in the video above.

  1. Select the bottle in the Hierarchy

  2. Expand the Rigidbody component and make sure that Use Gravity and Is Kinematic are toggled to on

  3. Expand the VR Attacahable Receiver and select the “Target” icon featured on the box next to Joint; the box should read “None (Base Joint).

  4. Once the new window opens, select the cap joint

  5. Expand the VR Grabbable component

  6. Set Snap Position to Always

  7. Set Snape Orientation to Always

  8. Select the cap in the Hierarchy

  9. Expand the Box Collider and set Is Trigger to On

  10. Expand the Rigidbody

  11. Toggle Use Gravity to On

  12. Toggle Is Kinematic to Off

  13. Expand the Mesh Collider and set Convex to On

  14. Expand the VR Attachable

  15. Expand Attached Grab Settings

  16. Toggle Working Surfaces Only to On

  17. Set Release Behaviour to Use Physics

  18. Expand Detached Grab Settings

  19. Toggle Working Surfaces Only to On

  20. Set Release Behaviour to Use Physics

  21. Select the “Target” icon featured on the box next to Attached To; the box should read “None (Base Joint).

  22. Select the bottle receiver

  23. Expand the VR Grabbable

  24. Toggle Allow Distance Grab to On

  25. Take your prefab variant and drop it into a VR scene

You should be able to use the bottle and cap the same way highlighted in the above video.

Troubleshooting

  • If you are concerned about the release behaviour of your cap. Remember that the release behaviours you define in VR Grabbable will always be overwritten in VR Attachable.

    • However, not all values set in VR Grabbable are mutual between itself and VR Attachable.

  • If the bottle and cap behaviour is not what you see in the video, be sure to double-check your component configurations. Specific changes to other components can affect one another.

  • If you see that specific configurations change during runtime during playtime, do not be alarmed. For example, values like Collision Detection, Use Gravity, etc., will all change when an object is dropped, grabbed, etc.

  • Do not treat Mesh Colliders and Box Colliders the same. For example, if you set Is Trigger to On in your mesh collider instead of the Box Collider on the bottle cap, the cap can be reattached but not nearly as fluidly.

  • Feel free to ignore prompts similar to these found at the top of VR Grabbable and Fixed Joint components. They are redundant.

Related Articles

Recipes

  • No labels