Creating/Connecting Mount Points

Creating a Mount Point – Example 1

Mount points must be created in the Unity editor. Once you’ve created mount points for an object, you can create a prefab just like you do any other object.

The mount points will be saved with the prefab.

1. Select the GameObject

2. Add the ‘Mount’ component

The Mount Points script is part of the ‘com.ootii.Actors’ namespace and can be found under:

Scripts\ootii\MountPoints\Actors\MountPoints

3. Add a mount point

Click the ‘+’ button under the ‘Mount Points’ section to add a mount point. Once added, rename the mount point something meaningful. It helps if mount points on the same object are uniquely named, but it’s not required.

4. Move and Rotate the Mount Point

Using the mount point’s editor handles, we can drag the mount point to the sword’s handle (if needed).

As discussed earlier, we know the avatar’s hand mount point will have the forward direction (blue arrow) coming out of the hand pointing in the direction of the blade. When we attach the sword to it, it will automatically rotate to have this
mount point’s orientation match that of the hand’s mount point.

So, we want to set the orientation of the mount point so that the forward direction (blue arrow) runs along the blade. Do this with the ‘Orientation’ fields in the inspector.

In this step, you’re really just going to be moving and rotating the mount points as you see fit.

5. Set Properties

Lastly, we set the properties for the mount point.

In this case, we want the sword to be a child and don’t expect to have anything use it as a parent. So, using a ‘Mount’ is fine.

In order to prevent the mount point from accidentally being moved or rotated, we’ll also set it as ‘Locked’ in the mount point list.

In order for a mount point to be a child and snap to a parent, it must be locked!

At this point, we’ve setup a mount point and placed it where we want it. We’ve also rotated it in the direction we want it facing. It doesn’t matter if you’re setting up a mount point you’re expecting to be a parent, a child, or both. They are all set up the same.

If needed, you could save this object as a prefab. This is great if you plan on creating the object through code later.

Creating a Mount Point – Example 2

In this example, let’s set up the mount point for the hand that would hold the sword. We won’t have as many pictures because the steps are pretty much identical.

1. Select the GameObject

2. Add the ‘Mount List’ component

3. Add a mount point

4. Move and Rotate the Mount Point

In this case, we’re going to move the mount point to the right hand. Then, we’ll rotate it (if needed) so the forward direction (blue arrow) is coming out of the hand.

5. Set Properties
Lastly, we set the properties for the mount point. In this case, we want the hand mount point to grab items (like the sword). So, we keep the ‘Allow Children’ check mark.

In order to prevent the mount point from accidentally being moved or rotated, we could set it as ‘Locked’. However, since this mount point won’t be the child of another mount point, I actually leave the ‘Locked’ flag off. The reason is that
it allows me to move the mount point while it’s holding something. It’s a good way to make sure it’s in the right position.

6. Set the Bone

So, this is a new option.

If we don’t set any bone value, the mount point is relative to the GameObject’s origin. That’s fine for objects that don’t have skeletons or animations. However, if you do have animations, we actually want the mount point to move.

In this case, we want the mount point tied to the avatar’s right hand bone. So, in the Mount Point Properties, we set the bone to ‘Unity RightHand’.

With that set, the mount point will move with the bone. Anything the mount point parents (like a sword) will move as well.

 

Connecting Mount Points – Editor

With two or more mount points setup, it’s now just a matter of moving the GameObjects so that the mount points are close enough to attract.

Remember that the object you’re moving is the child. When you let go of the drag handle, the child object will move to the position of the parent mount point (assuming they are close enough). Following our examples above, you’d move
the sword so it’s mount point is close to the right hand’s.

What you’ll see is that the child’s inspector will change a bit. The new parent object + mount point names will display along with an options to select the parent object or break their connection.

If you were to look at the parent mount point, you’d see that it lists the children connected to it: