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

Version 1 Next »

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

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

  2. First, we will right-click on the bottle in the Hierarchy window then select Motive > Make Grabbable

  3. After that, right-click on the bottle again and select Motive > Make Attach Receiver

  4. Next, when you expand the bottle in the Hierarchy window and right-click on the bottle cap, then select Motive > Make Grabbable

  5. Next, back on the bottle cap, right-click and select Motive > Joints > Add Fixed Joint

  6. Then, on the bottle cap, right-click and select Motive > Make Attachable

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

    1. Next, type in “Mesh Collider” and select Mesh Collider when it appears

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

  8. Once 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 and select Create Empty

      1. From there, you should be able to modify the Y Position value under the Transform component of the new empty object (Move it near the middle of the bottle lengthwise)

      2. Next, select the bottle and then open the VR Grabbable drag your new empty object into the black box next to Grab Anchor that reads “None (Transform)”

    2. Next, we will do the same thing for the cap of the bottle. Right-click on the cap and select Create Empty again

      1. Once again, modify the new empty objects Y Position value under Transforms so that it is somewhere near the center of the bottle cap

      2. Then select the cap and once again, under VR Grabbable, drag the new empty object into the same Grab Anchor box

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

  10. Firstly, the bottle will be configured. Select it in the Hierarchy, then

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

    2. Expand the VR Attacahable Receiver and select the Target icon featured on the box next to Joint; the box should read “None (Base Joint). Once the new window opens, select the cap joint

    3. Expand the VR Grabbable component

      1. Set Snap Position to Always

      2. Set Snape Orientation to Always

  11. Next, the cap should be configured. First, select it in the Hierarchy, then

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

    2. Expand the Rigidbody

      1. Toggle Use Gravity to On

      2. Toggle Is Kinematic to Off

    3. Expand the Mesh Collider and set Convex to On

    4. Expand the VR Attachable

      1. Then expand Attached Grab Settings

        1. Toggle Working Surfaces Only to On

        2. Set Release Behaviour to Use Physics

      2. Next, expand Detached Grab Settings

        1. Toggle Working Surfaces Only to On

        2. Set Release Behaviour to Use Physics

      3. Select the Target icon featured on the box next to Attached To; the box should read “None (Base Joint). Once the new window opens, select the bottle receiver

    5. Expand the VR Grabbable

      1. Toggle Allow Distance Grab to On

  12. Finally, if you 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.

  • No labels