Show / Hide Table of Contents

Using Behaviour System

VotanicXR has a built-in Behaviour System which provides a no-code interface for developers to implement simple application logic such as performing interactions, sending commands, moving object transforms, etc. This chapter introduces how to use the Behaviour System to create simple events in the VotanicXR application.

Tutorial Scene and Related Materials

Go to Assets > Votanic > VotanicXR_Tutorial > Tutorial08_BehaviourSystem and open the scene BehaviourSystem provided.

The tutorial scene has a DemoObjectGroup which contains a Door model and a Collisioner in front of the door. In this tutorial, we will setup a behaviour to open the door when the user walks in front of the door.

The Collisioner is a transparent GameObject with vGear_Collisioner script inside. It is used for triggering event when other GameObject collides with it. In the tutorial, we will use the Collisioner to trigger an open door event when the user walks into the Collisioner.

Behaviour Manager and Behaviour

In the VotanicXR Behaviour System, Behaviour Manager is the key component for controlling and managing every behaviour in the scene. Behaviour is an event-based trigger, if some condition(s) is fulfilled, then the corresponding action plan(s) will be performed. For each Behaviour, it can consist of at least one branch, where each branch has its respective trigger condition(s) and action plan(s).

Adding Behaviour Manager

The Behaviour Manager is the key component for the VotanicXR Behaviour system. It must be present in the scene for the Behaviour to function correctly.

  1. In the Hierarchy window, right-click and select vGear > GameObject > Behaviour Manager. A Behaviour Manager prefab will be added.

Creating Behaviour

  1. The BehaviourMangaer prefab has V Gear_Behaviour(Script) in Inspector window. Click Add Behaviour button will add a Behaviour sub item under the BehaviourManager.

  2. Select the new Behaviour prefab to configure the behaviour details.

    In the V Gear_Behaviour (Script), you can manage branch(es), and configure condition(s) and action(s) for each branch. The below figure and table show the layout elements and detailed description of a Behaviour.

    UI Element Description
    Add / Remove Branch to add or remove an if branch statement which consists of condition(s) and action(s) inside the branch. If the conditions are fulfilled, the actions will be performed.
    If multiple if branch statements exist, they will be checked sequentially. Only the first matched if branch statement will be performed. All the subsequent branches will be skipped.
    Add / Remove Trigger Trigger is the condition group of the branch. If the condition(s) inside the Trigger group are fulfilled, the corresponding action(s) will be executed. If several trigger groups are setup, the action will be executed if one of the trigger group is fulfilled.
    Add / Remove Plan Plan is the action group of the branch. if the plan is executed, actions inside the plan will be performed.
    If multiple plans existed, developer can specify a probability for each plan, indicating the chance in which the particular plan will be executed.
  3. The behaviour name can be changed to other meaningful name for identification. In this example, we name the behaviour as Open door behaviour. Then, click Add Branch to create an if branch statement and name it as Use collisioner to open the door. In the branch, click the Add Condition and Add Action button to create a Trigger and a Plan group and name it as Collision with collisioner and Open the door, respectively.

  4. Then, click the Condition 1 button to open the Condition popup window to setup the trigger condition. In the popup window, configure the properties as follows:

    • Name: Hit collision (for identification, you can use other meaningful wording)
    • Type: Collision
    • Collisioner: Collisioner GameObject

    After that, the popup windows can be closed.

    Note: apart from the Collision type, there are other types can be used for condition checking. The detailed information can be checked from this link.

  5. Next, click Action 1 button to open a Action popup windows to setup the action. In the popup windows, configure the properties as follows:

    • Name: rotate the door transform (for identification, you can use other meaningful wording)
    • Type: Transformation
    • Number of Objects: 1
    • Objects: Pivot
    • Rotation: X: 0, Y: -90, Z: 0

    Note: apart from Transformation type, there are other actions can be used. The detailed information can be checked from this link.

  6. After the configuration, the behaviour should be similar to the below figure.

  7. The result of this example will be as follows: when the user goes in front of the door and hits the collisioner, the door will open automatically.

In This Article
Back to top Generated by DocFX