Use a custom script event to control the flow of the scenario
In this tutorial, we will dive deeper into Events. As an overview please review this resource:
In our last tutorial, we added some character dialog, but right now, the character speaks as soon as the scenario begins. It would be better if they waited until the initial notification was cleared. We will use custom script events to make that happen.
Step 1: Create a Custom Event
- Open the "Welcome Message" script and ensure it is your active tab:
- Open the "Events" tab in the tools panel on the right-hand side of the editor:
- Click "Add New".
- Create an event called "Welcome message script complete".
- Check the "Global" trait - this will allow you to use this event in other scripts.
- Click on the checkmark in the top right to save.
Step 2: Create a New Subframe Using the Event-link Shortcut
- Navigate to the "Notification" frame in the script:
- Use the event link short cut on the bottom of the notification resource to create a new subframe that will open when the notification closes:
Step 3: Add the Custom Event to The New Frame
- Drag the event you created into this new frame. This event will now fire after the notification closes:
- Save the script. You could test the scenario too - but nothing will have changed yet.
Step 4: Open the "Conversation" Script
- Now, go back to (or open) the "Conversation" script.
- Navigate to the final frame in the script (in this case "Stacey Greets User"):
Step 5: Add a Custom Event Condition to this Frame
Right now, this frame opens as soon as the script is launched. Instead, we'd like this frame to run after the notification in the "Welcome Message" script is complete. If we create an event that listens for the "Welcome message script complete" event we just created, we can make this happen.
- Open the events panel in this frame and find the event you created (if it isn't there, you may have forgotten to toggle the "Global" trait.)
- Drag this event into the conditions section of the editor. This will create a custom event condition:
- STOP: Save and test. You should now see that your character does not speak until the notification clears.
In the Headset
This is what your scenario will look like so far:
Key Takeaways from Tutorial 6
- Events occur throughout a scenario and can be used to track progress and control scenario flow.
- Global Events are events that can be used across all scripts.