Interaction Events

These components will allow you to introduce interactions with environment like doors, lights, fireworks
Now that we have set up our behaviour logic, how do you allow users in HoloFair to interact with these objects?
Here we have interactions events. These UnityEvents are invoked by user interaction in HoloFair, meaning you can predefine certain behaviour and logic of what each interaction does through the Unity Editor.


The following event is invoked on Start, which is when the venue is loaded. Pretty simple to use.


When you need a specific behaviour when a player collides with trigger collider, you can use OnTriggerHandler.
Add OnTriggerHandler to an object that has any type of collider that is marked as a IsTrigger.
There is the property TargetTag, which allows you to specify which tag should the trigger look out for. Most of the time, we only look out for our local user, so keep the LocalPlayer tag.
The events are for three types of interaction with trigger colliders. When the user enters the trigger, OnTriggerEnter is invoked. When the user leaves the trigger, OnTriggerExit is invoked. On every fixed update, if the player is within the trigger collider, OnTriggerStay is invoked.


To create interactable objects within your world, you'll need to use OnClickHandler.
Create a Tag named "Interactive" as Tag 1 in the Tags list.
Add OnClickHandler to an object that has any type of collider that is marked as a IsTrigger and set its Tag as "Interactive".
Firstly, the most important properties of this components are its events. OnEnter is invoked when the user's mouse hovers over the trigger. OnExit is invoked when the user's mouse leave the trigger. OnClick is invoked when the user long-clicks on the trigger.
Use Hold Interaction Time to set hold duration required for the event to fire.
Notice that if you leave it 0, the click will fire immediately, no hold required.
Additionally, you may replace the cursor with a Texture of your choice to give the user better feedback as to what's going on. Reference the texture of choice in the Cursor Texture field and call OnClickHandler.ReplaceCursor(true) OnEnter and OnClickHandler.ReplaceCursor(false) OnExit as demonstrated below.
Usually, you'd leave Cursor Mode and Hot Spot as their default values. For more information on how ReplaceCursor works, see this.