Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This article describes how you can implement Motive’s premade Sliding Joint component to connect 3D assets and have them interact as if they were connected on rails. With only a few minor changes made in Unity, this functionality allows for easy and fast interaction that can be used in conjunction with other Motive premade features such as, VR Attachable, VR Attachable Receiver and VR Grabbable. After that, we will cover how we can check object states related to sliding objects in order to trigger events on Storyflow.

...

Setup - Unity SDK

  1. Open your Unity project and in the scene Hierarchy window select (World > Example Assets > Props > Workbench > Workbench_LOD0 > Bench Top)

    1. Under the Mesh Collider component turn Is Trigger to off

    2. Scroll down to the bottom of the Inspector window and select (Add Component > (Type in “Rigidbody”) > Rigidbody)

    3. In the Rigidbody component toggle Use Gravity to off and toggle Is Kinematic to on

  2. Then in the Hierarchy window select (World > Example Assets > Props > Workbench > Stud > Stud)

    1. In the Rigidbody component toggle Use Gravity to off and toggle Is Kinematic to on. After that set your Collision Detection to Discrete

    2. In the Mesh Collider component toggle Is Trigger to off

  3. Right-click on Stud in the Hierarchy window and select (Motive > Make Grabbable)

    1. Scroll down to the new Mesh Collider component and delete it by selecting the *Three dots* on the top right of the component, then select Remove Component

    2. In the new VR Grabbale component make sure that Allow Distance Grab is toggled off

    3. In the Snap Position and Snap Orientation dropdown menus make sure both values are set to Never

    4. Toggle Track Orientation to off

    5. Set Release Behaviour to Leave In Place

    6. Then change Move Mode to Physics

  4. While you are still in the Stud Inspector window scroll down to the bottom and select (Add Component > (Type in “String State Setter”) > String State Setter)

    1. In the State textbox type “Plank Position”

  5. Back in the Hierarchy window right-click on Stud and select (Motive > Joints > Add Sliding Joint)

    1. In the new Sliding Joint component under Axis change the X value to 0 and set the Y value to 1

    2. Under Secondary Axis set the X value to 1 and the Y value to 0

    3. Next, select the *Target* icon for the Connected Rigidbody area and then select Bench Top

    4. Then, toggle Limit Motion to On

    5. In the Lower Limit text area type “-0.2” and for the Upper Limit type “0.4”

    6. Expand the Upper Stop dropdown menu and under Limit Threshold type “0.2”

      1. Next in the In Limit() area hit the + icon then drag Stud from your Hierarchy window into the box that reads None (Object)

      2. Then, expand the No Function dropdown menu and select (StringStateSetter > SetState (String))

      3. In the *Newly Created Textbox* type “Outside”

    7. Expand the Lower Stop dropdown menu and under Limit Threshold type “0.1”

      1. Next in the In Limit() area hit the + icon then drag Stud from your Hierarchy window into the box that reads None (Object)

      2. Then, expand the No Function dropdown menu and select (StringStateSetter > SetState (String))

      3. In the *Newly Created Textbox* type “Inside”

  6. Save the scene

...