Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
In depth learning on Scene Configuration can be found in this course in Motive Academy. |
Overview
This article describes how you can implement Motive’s premade Sliding Joint component to connect 3D assets 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.
...
Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Setup - Unity SDK
Open your Unity project and in the scene Hierarchy window
...
Right-click on World then select (Create Empty) and name your new empty object “Slide Remove Example”
...
select World > Example Assets > Props > Workbench > Workbench_LOD0 > Bench Top
Under the Mesh Collider component turn Is Trigger to off
Scroll down to the bottom of the Inspector window and select Add Component > (Type in “Rigidbody”) > Rigidbody
...
...
In the Rigidbody component toggle Use Gravity to off
...
Toggle Is Kinematic to on
...
Right-click on Slide Remove Example and make a child object by selecting (3D Object > Cube)
Name this cube “Stationary Cube”
In the Stationary Cube Inspector window under the Box Collider component toggle Is Trigger to on
Next, add a Rigidbody to the Stationary Cube as you did before
Once again you need to toggle Use Gravity to off and Is Kinematic to on
...
Right-click on Stationary Cube and make a child object by selecting (Create Empty)
Name this object “Sliding Joint”
Right-click on the Sliding Joint and select (Motive > Joints > Add Sliding Joint)
In the Rigidbody component disable Use Gravity
In the Sliding Joint component click on the box next to Connected Rigidbody and delete that object
Into that same box drag the Slide Remove Example object you just made
Next, in the same component toggle Limit Motion to true
Then in the box beside Upper Limit type 0.1
...
Then in the Hierarchy window select World > Example Assets > Props > Workbench > Stud > Stud
In the Rigidbody component toggle Use Gravity to off
Toggle Is Kinematic to on
Set your Collision Detection to Discrete
In the Mesh Collider component, toggle Is Trigger to off
Right-click on Stud in the Hierarchy window and select Motive > Make Grabbable
Scroll down to the new
...
In the new Element 0 area drag in Stationary Cube
Right-click on Sliding Joint and make a child object by selecting (Create Empty)
...
Name this object “Removable Part”
...
Right-click on the Removable Par and select (Motive > Make Grabbable)
...
In the VR Grabbable component toggle Track Orientation to off
...
Mesh Collider component and delete it by selecting the *Three dots* on the top right of the component, then select Remove Component
...
In the new VR
...
Grabbale component, make sure that Allow Distance Grab is toggled off
In the Snap Position and Snap Orientation dropdown menus, make sure both values are set to “Never”
Toggle Track Orientation to off
Set Release Behaviour to Leave In Place
Then change Move Mode to Physics
While you are still in the
...
Stud Inspector window scroll down to
...
the
...
Then slightly lower you can toggle Requires Detachable to on
...
Next, expand the Guide Meshes dropdown and increase Size to one
...
bottom and select Add Component > (Type in “String State Setter”) > String State Setter
In the State textbox type Plank Position
Back in the Hierarchy window right-click on Stud and select Motive > Joints > Add
...
Sliding Joint
...
Right-click on Removable Part again and select (3D Object > Cube)
Name this cube “Sliding Cube”
...
Go back to Removable Part now under the VR Attachable find Element 0 under the Guide Meshes dropdown
Drag Sliding Cube into the box beside Element 0
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 ()
...
In the new Sliding Joint component under Axis change the X value to 0 and set the Y value to 1
Under Secondary Axis set the X value to 1 and the Y value to 0
Next, select the *Target* icon for the Connected Rigidbody area and then select Bench Top
Then, toggle Limit Motion to On
In the Lower Limit text area type as -0.2 and for the Upper Limit type as 0.4
Expand the Upper Stop dropdown menu and Under Limit Threshold type 0.2
Next in the In Limit() area hit the + icon then drag Stud from your Hierarchy window into the box that reads None
...
(Object)
Then, expand the No Function dropdown menu and select
...
StringStateSetter >
...
SetState (String)
...
Next, you must select the Slide Remove Example object and either using 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
(X: 1.588, Y: 0.448, Z: 2.139 works well)
...
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
...
Then select Sliding Cube in the Hierarchy window and change its scale values to 0.3
...
Then, using the *Arrows* as mentioned before or the Position fields under the Transform component you should move Sliding Cube so it is visible
These position values work well (X: 0, Y: 0.62, Z: 0)
...
Save the scene
...
In the *Newly Created Textbox* type Outside
Expand the Lower Stop dropdown menu and under Limit Threshold type to 0.1
Next in the In Limit() area hit the + icon then drag Stud from your Hierarchy window into the box that reads None (Object)
Then, expand the No Function dropdown menu and select StringStateSetter > SetState (String)
In the *Newly Created Textbox* type Inside
Save the Scene
Setup - Storyflow
Create the Enum
Select the *Three Bullet List* icon on the right side of the screen (Reference Image Below)
Next, select New Enum Name and type Plank Position
After that, hit the > left of where it reads Plank Position and then select New Enum Item Name then type Inside
Do this a second time but type Outside
Set up the Catalog
Open Storyflow and select the Catalogs tab
If you do not have a “Named
...
Object” Catalog already, select
...
Create > Select Type > Named
...
Object > (Type a name) > Create
...
Open your “Named
...
Object“ Catalog then select
...
+ > Named Anchor > (Type in
...
“Stud”) > Save
...
Save the
...
Catalog
If you do not have a “Behaviour Model” Catalog already, select Create > Select Type > Behaviour Model > (Type a name) >
...
Create
Open your “Behaviour Mode“ Catalog then select + > Behaviour Model > (Type in “Stud Behaviour Model”)
Then select States + > (Type in Plank Position)
Expand the Primitive dropdown menu and change it to Enum
After that, expand the NOT SET dropdown menu and select Plank Position
Save the Catalog
Scripting
Open the Scenarios tab and Create a New Script
Open the new Script
Under Resources on the right side of the screen click and drag the
...
Scene Object Resource into
the grey area in the center of the screenSelect
...
Object + > (Your Named Object catalog) >
...
Stud
In the same grey area mentioned before
...
“Screen Message” can be typed into the Resource search bar for easy access
...
Select the drop-down menu under Anchors and select Anchor1
...
Under Text type “Great work”
...
Select Save on the top left of the screen
...
, drag and drop in the Behaviour Model Resource
Select Targets + > Stud
Then, select Behaviour Model > (Your Behaviour Model catalog) > Stud Behaviour Model
Select the + icon attached to the “Main Frame” on the left side of the screen to create a new Frame
Select the newly created Frame and in the same grey area mentioned before, drag and drop in the
Set Object State ResourceSelect World Objects + > Stud
Then, select Behaviour Model > (Your Behaviour Model catalog) > Stud Behaviour Model
Select CHOOSE STATE > Plank Position > Compare +
In the new Value dropdown list select Outside
Next, select the blue + icon on the bottom right of the Set Object State resource, scroll down the list that appears and select Close
In the newly created frame, add the Notification Resource and under Message type Outside
Again, select the + icon attached to the Main Frame on the left side of the screen
Select the newly created Frame and in the same grey area mentioned before, drag and drop in the
Set Object State ResourceSelect World Objects + > Stud
Then, select Behaviour Model > (Your Behaviour Model catalog) > Stud Behaviour Model
Select CHOOSE STATE > Plank Position > Compare +
In the new Value dropdown list select Inside
Next, select the blue + icon on the bottom right of the Set Object State resource, scroll down the list that appears and select Close
In the newly created Frame, add the Notification Resource and under Message type Inside
Select Save on the top left of the screen
Create a Scenario, if there isn’t one already
Link the Script you created to the Scenario
You can now open your Unity project select Project. Select the newly created scenario, and see your newly made notification!Scenario, once it has loaded you should be able to grasp the Stud from the workbench, slide it to the left, and read your new Notifications!