Pointing

Pointing is a common way to guide the player's attention to a specific object or location. TutorialMAX provides a convenient way to design hand pointers on the Canvas and 3D pointers in the world.

Quick Start

You can find pre-made pointer prefabs at Assets/TutorialMAX/Prefabs/Pointers. With some tweaks you can customize them to your liking. They are also good starting points for creating your own pointers with your own sprites and desired behaviors.

To use the pointer, drag the Canvas Hand Pointer prefab onto a Canvas object inside the scene. Then follow the instructions at the Testing section.

If you want to create a pointer from scratch, that is also possible, and is not difficult either.

In the case of Canvas pointers, you might want to place them as the last children of Canvas to make them appear on top of other objects.

Creating Pointers From Scratch

1. Creating the Pointer Object

Create a pointer by right-clicking on the hierarchy and selecting TutorialMAX => Pointer. This will create an object with the TutorialPointer component defined on it.

2. Configuring the Transform Handler

The pointer component doesn't really provide any actual pointing functionality on its own. Thus the next step is to configure the pointer to move around and point at stuff. Click on "Add Behavior" and select "Transform Handler".

First and foremost, set Coordinate Mode to either Screen or World depending on your use case. Conversion Depth is rarely used; only when pointing at an on-screen object with a 3D pointer.

Now you need to configure the following transforms:

  • Root: Select the main transform that you want to be transformed when pointing. Leave empty to use the same transform it's defined on.
  • Hotspot: A transform that represents the point where the pointer should be pointing at. For example, in case of a pointing hand, the tip of the index finger is typically the hotspot.
  • Pointing Source: A transform that is used in conjunction with the Hotspot transform to calculate the direction in which the pointer should be pointing. For example, in case of a pointing hand, this could be the wrist.

The rest of the options are for configuring the behavior of animations on the pointer.

3. Configuring Appearance/Disappearance

By now, you should already have a functioning pointer. Except that it doesn't know how to appear and disappear.

Depending on your requirements, your pointer might either have one or more MeshRenderer components, or it could be on Canvas. First click on "New State Behavior Group" on the pointer component. On the behavior group component of the new GameObject, make sure StateFilter is set to Visibility and IsTrue is checked.

  • If on Canvas, add a Canvas Group to the root GameObject and add a UI => Canvas Group Alpha behavior to the behavior group.
  • If using a MeshRenderer, add a Renderer => Material Tint behavior to the behavior group.

If you're using neither Canvas Group nor MeshRenderer, you can still create your own behavior scripts as usual!

Testing

There are multiple ways to try out a pointer. The simplest one is to create a ManualBehaviorGroup and add a Pointer => Point behavior on it. Select the reference to the pointer you just created. Specify a Target transform to point at and optionally configure the transform pipeline. Set InitiallyActive on the behavior group to true and hit Play.