Immerse

📘

In addition to this section, learn more about Interaction Requirements and Reactions and interaction logic.

Description

The Immerse Platform makes it easy to deploy scenes containing interactive objects, which can be interacted with by multiple users. Once an object has moved or been placed somewhere, another event sometimes needs to be triggered. To enable this, the Immerse SDK uses a concept of snapping, allowing one or more expected orientations (called Snap Targets) to be set for an object. Once defined, specific actions can be triggered when the object is placed near the location of the Snap Target.

Snapping can be used in a variety of scenarios:

  • One Pickup object can be snapped to another Pickup object (such as the mini rocket in the Immerse Demo Scene "Moon Room"), to create larger Pickup objects.
  • A Pickup object can be snapped to any other geometry, for instance picking up and replacing a virtual 'hand drill' on a wall.
  • A Dial can have Snap Targets placed at discreet rotations to indicate certain states, such as "Min" or "Max". When snapped, the dial will stay in place.
  • A Lever can have Snap Targets placed at discreet rotations such as "Min", "Med", "Max, etc.
  • A Door, can be "Open" or "Closed"

As a core SDK feature, Snap Targets are automatically synchronised using the TransformSync component, along with location and rotation requiring no special code.

Snap Targets are set up by associating a TransformSync with a list of valid Snap Targets; a Snap Target can be associated with more than one TransformSync (it is a many-to-many relationship).

When an object is snapped, its physics are disabled by default, to ensure it stays in place, however this can be overridden, to keep physics enabled after snapping too. A good example of physics staying enabled after snapping can be seen in the Immerse Demo scene Basket Ball station. When balls snap to their start positions, they immediately roll down the ramp to the bottom of the tray.

When an object is held near to a Snap Target, it's green "ghost" image will be displayed, indicating where it will end up with the trigger is released. This is called a Snap Preview and can be disabled if necessary.

A clearly visible Snap Preview for the rugby ball

After snapping an interactable object to a Snap Target, it will be reparented to that Snap Target by default. This behaviour can be disabled, applying only the position and rotation of the target to the object, instead of reparenting it.

If TransformSync is set to Snap to Origin, a new Snap Target will be added at start-up, which will mirror the original position and rotation of the object. This is useful if the object needs to be returned to its starting point at any point.

Once snapped, it is possible to optionally prevent an object from being moved again, by disabling its interactions. This can be achieved with Interaction Requirements. Similarly, interactions can be prevented and only enabled once certain requirements are valid. This is useful if there is a sequence of tasks that a user needs to complete.

Instead of using the Unity Scene View, Snap Targets (and ensuring that objects snap) can be performed at runtime, via scripting.

🚧

TransformSync state

The "state" of the TransformSync is an integer which refers to the index of the Snap Target in the list of valid targets. If the state is 255, then the object is not snapped.

How to implement

1 Select a GameObject as a new Snap Target.
Note: This object must be a sibling, not a child, of the interactable object. If a child is selected, the Snap Target will move along with the interactable object, which will not work. A common technique is to parent the interactable object and all its Snap Targets under a common root. This root can be moved as a whole, if required.

  1. Set the Snap Target object's position and rotation to the location where the interactable object will be snapped (see below)
  2. Add an ImmerseSDK.Interaction.SnapTarget component.
  3. Select the interactable object (with the TransformSync component)
  4. Drag the new Snap Target onto the Snap Targets property on the TransformSync to add it.
  5. Select the Snap target again, and set options (see below).

To easily orientate a Snap Target

  1. Select the interactable object (the part that contains the TransformSync)
  2. Move and rotate this interactable object to its desired snapping position
  3. Right-click in the Inspector View of the Transform component, and select [Copy Component]
  4. Select the Snap Target object
  5. Right-click in the Inspector View on the Transform component, and select [Paste Component Values]. The Snap Target object will now be oriented correctly.
  6. Revert the interactable object back to its original position

Hint: A Snap Target can be disabled at runtime by disabling the GameObject it is on. Any disabled Snap Targets will not be considered when the object is snapped.

Unity Editor Component

Options

PropertyDescription
Reparent when snapped
Adds the snapped object as a child to the snap target object.
Allow physics when snapped?Enable if you need the snapped object to have physics enabled after snapping
Is Occupied?When a snap target is occupied, it cannot be used. You can also disable the GameObject that the snap target is on.
Alternative Preview ObjectWhen this is set, the SDK will generate a ghost preview of the meshes in this hierarchy and use that instead of the target interactable object's mesh. This is useful in scenarios where the snapped object looks different from the interactable object.
Include Local Rotation AxisIf these are ticked, then both location and rotation will be tested (with a certain amount of error) for a valid target to match the object's orientation.
Note: Either tick them all, or untick them all. If you tick only one axis, them we have to resort to Euler angels to do the test, and this suffers from Gimbal Lock.
Snapping RequirementsOnly when all these requirements are met can the object be snapped. See Interaction Requirements for more details.

Updated 4 months ago


Snapping


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.