Web XR engine
Comment on page

Visual Scripting

Visual Scripting allows you to create complex behaviour and add interactions without coding skills. Add music when the Player approaches some area, turn on the lighting by pressing the button, and many other scenarios. Use predefined playbooks or create new with 8XR Visual Scripting.
With Visual Scripting, you can construct an interactive 3D scene without any programming experience. If you are familiar with UE Blueprint or Unity Visual Script, you will find lots of similarities in 8XR Visual Scripting.
To create a new Script, open the Assets Manager by clicking the Assets button on the top panel of the Editor
Open Asset Manager
Press the Add Asset button and choose Script
Create a new Visual Script
Enter the name of the Script and press the Edit button
Start editing the Visual Script
It will open a new Script Editor window. It consists of the following parts:
Script Editor window
As an example, the guide will demonstrate how to create a Script to control the Animation of a 3D model.
Start with adding a 3D model and attaching the desired animation to it. Animation is a Model Modification that you can add by pressing the "+" button in the Model Inspector.
Ensure to disable the Autoplay parameter of the Animation.
3D model with attached Animation
You can find the Model we used in this example here.
To add a new Node in Script Editor, right-click on the Canvas Zone or press the Add Node button and select the required Node. Find Collision Start Node and click on it. This type of Node will be triggered when any entity with a Physics Body collides with the entity with the current Script attached.
Great! Now add a few other Nodes: Cast to Player, Animation, and Play Animation.
Connect the Nodes to each, as shown in the picture bellow:
Connected Nodes
You have just created your first Script, which does the following: "When there is a Collision between the current Entity (the Entity to which the Script is attached) and the Player, play the Animation."
Now we need to choose the Animation to play. In the Animation Node select the Model Entity and choose the desired Animation.
Selecting the Animation
Close Script Editor.
As the next step, we need to create an object that will trigger the Script we have just created. Open Entity Add menu and select Trigger Volume
Create a Trigger Volume
Attach the Script you have just created to the Trigger Volume Entity. The Script is attached with a Script Modification. Each Entity can have multiple Scripts attached.
Attach the Script
You did it! It is time to test the results. Launch the Scene by pressing the Play button. Step into the Trigger Volume Entity. The animation should start playing.

Script Parameters

Script Parameters are used to make a Script reusable in different places.
Let's rework the Script you have just created by converting its Animation to a parameter specified when the Script is attached to an Entity.
Open Script Editor and add a new Script Parameter Animation.
Add a new Script Parameter Animation
Choose the name of the parameter and drag-and-drop it into the Canvas.
Name the Parameter and drag-and-drop into the Canvas
Replace the current predefined Animation with the Animation Parameter you have just created.
First, delete the Animation Node by selecting it and pressing the "backspace" keyboard button.
Next, rework the Script as shown in the picture bellow.
Rework the Script as shown on the picture
Close Script Editor.
Click on the Trigger Volume you have attached the Script to. The Animation Parameter can now be seen in the Script Modification Inspector.
The Animation Parameter in the Script Modification Inspector
Well Done! Now you can choose the Animation without modifying the Script. You can use this Script with a variety of Entities and Trigger Volumes.
You have just created a tool that allows you to play a generic Animation when the Player enters a predefined area in your 3D Scene.
Try the Script with a different Model