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 find “World”

  2. Right-click on World then select (Create Empty) and name your new empty object “Slide Remove Example”

  3. In your Slide Remove Example Inspector 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)

    1. Toggle Use Gravity to off

    2. Toggles Is Kinematic to on

    Right-click on Slide Remove Example and make a child object by selecting (3D Object > Cube)

    1. Name this cube “Stationary Cube”

    2. In the Stationary Cube Inspector window under the Box Collider component toggle Is Trigger to on

    3. Next, add a Rigidbody to the Stationary Cube as you did before

      Once again you need to

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

    Right-click on Stationary Cube and make a child object by selecting (Create Empty)

  4. Name this object “Sliding Joint”

  5. Right-click on the Sliding Joint and select (Motive > Joints > Add Sliding Joint

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

    1. In the Rigidbody component disable toggle Use Gravity

    2. In the Sliding Joint component click on the box next to Connected Rigidbody and delete that object

    3. Into that same box drag the Slide Remove Example object you just made

    4. Next, in the same component toggle Limit Motion to true

      1. Then in the box beside Upper Limit type 0.1

    Right-click on Sliding Joint
    1. 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

  6. Right-click on Stud in the Hierarchy window and select (Motive > Make Attach ReceiverGrabbable)

    1. Scroll down to the new Attach Receiver component expand the Colliders dropdown and expand the Size to 1

    2. In the new Element 0 area drag in Stationary Cube

    Right-click on Sliding Joint and make a child object by selecting (Create Empty)

    1. Name this object “Removable Part”

    2. Right-click on the Removable Par and select (Motive > Make Grabbable)

    3. In the VR Grabbable component toggle Track Orientation to off

    4. Find the Box Collider component and select the Mesh Collider component and delete it by selecting the *Three dots* on the top right of the component, then select Remove Component

    5. Under In the new VR Attachable component expand the Attached Grab Settings dropdown then select the Release Behaviour dropdown and then click on Leave in Place Then in the same Attached Grab Settings dropdown change the Move Mode to Grabbale component make sure that Allow Distance Grab is toggled off

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

    7. Toggle Track Orientation to off

    8. Set Release Behaviour to Leave In Place

    9. Then change Move Mode to Physics

  7. While you are still in the

    VR Attachable component

    Stud Inspector window scroll down to

    find

    the

    Attached To field, and delete whatever object is in that box
  8. Then slightly lower you can toggle Requires Detachable to on

  9. Next, expand the Guide Meshes dropdown and increase Size to one

  10. Right-click on Removable Part bottom and select (Add Component > (Type in “String State Setter”) > String State Setter)

    1. In the State textbox type “Plank Position”

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

  12. Right-click on Removable Part again and select (3D Object > Cube)

    1. Name this cubeSliding Cube”

  13. Go back to Removable Part now under the VR Attachable find Element 0 under the Guide Meshes dropdown

    1. Drag Sliding Cube into the box beside Element 0

  14. Now, go back to Sliding Joint and under the Sliding Joint component in the Upper Stop dropdown menu, you need to hit the + icon under In Limit ()

    1. Then, you need to drag Removable Part 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

      From there select
      1. (Object)

      2. Then, expand the No Function dropdown menu and select (

      VR Attachable
      1. StringStateSetter >

      SetDetachable
      1. SetState (String))

    Next, you must select the Slide Remove Example object and either using
      1. In the *

    Arrow* shown in the Scene view or the Position values under the Transform component you just move the object somewhere easily accessible in the Workshop scene
    1. (X: 1.588, Y: 0.448, Z: 2.139 works well)

  15. After, that it would be best to reduce the Slide Remove Example Scale to 0.5 on both the X, Y and Z axis, these values can also be found under the Transform component

  16. Then select Sliding Cube in the Hierarchy window and change its scale values to 0.3

  17. Then, using the *Arrows* as mentioned before or the Position fields under the Transform component you should move Sliding Cube so it is visible

    1. These position values work well (X: 0, Y: 0.62, Z: 0)
      1. Newly Created Textbox* type “Outside”

    2. 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”

  18. Save the scene

Setup - Storyflow

  1. Open Storyflow and select the Catalogs tab

  2. Select the *Three Bullet List* icon on the right side of the screen (Reference Image Below)

    Image Added
    1. Next, select New Enum Name and type “Plank Position”

    2. After that, hit the > left of where it reads Plank Position and then select New Enum Item Name then type “Inside”

      1. Do this a second time but type “Outside”

  3. If you do not have a “Named Anchor” Object” catalog already, select (Create > Select Type > Named Anchor Object > (Type a name) > Create)

    1. Open your “Named

    Anchor“
    1. Object“ catalog then select (+ > Named Anchor > (Type in

    “Anchor1”
    1. “Stud”) > Save)

    2. Save the catalog

  4. If you do not have a “Behaviour Model” catalog already, select (Create > Select Type > Behaviour Model > (Type a name) > Create)

    1. Open your “Behaviour Mode“ catalog then select (+ > Behaviour Model > (Type in “Stud Behaviour Model”))

    2. Then select (States + > (Type in “Plank Position”))

    3. Expand the Primitive dropdown menu and change it to Enum

    4. After that, expand the NOT SET dropdown menu and select Plank Position

    5. Save the catalog

  5. Open the Scenarios tab and select (+ Add a New Script > (Type a name) >
    Checkmark > (Newly Created Script))

  6. Under Resources on the right side of the screen click and drag the “Scene Anchor” Object” resource into
    the grey area in the center of the screen

    1. Select (Anchor Object + > (Your Named Object catalog) > Anchor1 > SaveStud)

  7. In the same grey area mentioned before put the Guide “Screen Message” resource there

    1. “Screen Message” can be typed into the Resource search bar for easy access

  8. Select the drop-down menu under Anchors and select Anchor1

  9. Under Text type “Great work”“Behaviour Model” resource there

    1. Select (Targets + > Stud)

    2. Then, select (Behaviour Model > (Your Behaviour Model catalog) > Stud Behaviour Model)

  10. Select the + sign attached to the “Main Frame” on the left side of the screen

  11. Select the newly created frame and in the same grey area mentioned before put the
    “Set Object State” resource there

    1. Select (World Objects + > Stud)

    2. Then, select (Behaviour Model > (Your Behaviour Model catalog) > Stud Behaviour Model)

    3. Select (CHOOSE STATE > Plank Position > Compare +)

    4. In the new Value dropdown list select Outside

  12. Next, select the blue + icon on the bottom right of the Set Object State resource, scroll down the list that appears and select Close

    1. In the newly created frame add the “Notification” resource and under Message type “Outside”

  13. Again, select the + sign attached to the “Main Frame” on the left side of the screen

  14. Select the newly created frame and in the same grey area mentioned before put the
    “Set Object State” resource there

    1. Select (World Objects + > Stud)

    2. Then, select (Behaviour Model > (Your Behaviour Model catalog) > Stud Behaviour Model)

    3. Select (CHOOSE STATE > Plank Position > Compare +)

    4. In the new Value dropdown list select Inside

  15. Next, select the blue + icon on the bottom right of the Set Object State resource, scroll down the list that appears and select Close

    1. In the newly created frame add the “Notification” resource and under Message type “Inside”

  16. Select Save on the top left of the screen

  17. Next, select the Project tab on the top of your screen then go (Create > Script + >
    [Project name] Scripts > (Your new script) > Title > (Type a new scenario title) >
    Save)

...

You can now open your Unity project select the newly created scenario, and see your newly made notificationonce it has loaded you should be able to grasp the Stud from the workbench slide it to the left and read your new notifications!