Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconId1f393
panelIcon:mortar_board:
panelIconText🎓
bgColor#4C9AFF

In depth learning on Usable World Objects is found in this course in Motive Academy.

Table of Contents
minLevel1
maxLevel6
outlinefalse
typelist
printablefalse

Overview

Demonstrates how to configure a usable barcode reader that shines a light on activation. Uses this the Barcode Scanner asset as a base:

https://assetstore.unity.com/packages/3d/props/electronics/barcode-scanner-177384

, found here.

Step 1: Scene Object

  1. To start, we’ll add a Motive Scene Object to the “main” part of the scanner since this is the part the user will be using:

...

Step 2: Pick up the Scanner

  1. Now we want to make the main part of the reader grabbable. Right-click “main” and choose “Make Grabbable” from the Motive menu:

...

You’ll notice that when you grab from a distance, the grip is far too low on the handle.

  1. Let’s add a grab anchor to fix that:

...

  1. Assign this object to the Grab Anchor property on the Grabbable:

...

    ...

    1. Add a light that we can turn on when the scanner is being grasped and the trigger is held down. Add a Spot Light like this:

    ...

    You can adjust the light settings to fit your needs. Note that the light is disabled by default.

    1. Now let’s connect an Action on the Grabbable to turn this light on & off. Connect Grab Trigger Down and Grab Trigger Up to enable & disable the light:

    ...

    The scanner should now shine a light while the trigger is held down:

    ...

    1. Finally we can make this Usable by adding a Point and Shoot action:

    ...

    See Usable World Objects for more information about Usables. This action fires when the user points at an object and pulls the trigger. It uses a raycast.

    1. We want the raycast to originate from the light source, so let’s set the Raycast Transform:

    ...

    Step 3: Attach to Base

    With these settings, the scanner will return to its base after you drop it, but sometimes the user will simply want to place the scanner back in its cradle. We can achieve this by making the scanner Attachable and making the base an Attachable Receiver.

    1. Right-click on “main” to “Make Attachable”.

    2. Right-click on “base” to “Make Attach Receiver”.

    3. Drag “base” onto the “Attached To” field of “main”. This assigns “base” as the default Attach Receiver for “main”.

      Image Modified

    Now when you reach to replace the scanner, you’ll see a highlight indicating that you can place it back in the base. However, with this configuration, you’ll likely notice that the highlight flashes on and off. This is because both base and main have been assigned mesh colliders by the Motive builders. Unity does not handle collision detection between mesh colliders very well.

    1. To alleviate that, let’s replace the mesh collider on base with a box collider:

    ...

    With this in place, the collision detection will be much smoother and the highlight will be more stable.

    Related Articles

    Configure One Object to be Used On Another

    Hand-Activated Sanitizer

    Usable Actions - Point And Shoot