December 9, 2022
In this VR Builder tutorial, you will learn how to use the delay behavior to create timed effects. As the name suggests, the delay behavior is useful for delaying steps. First, we will explain how to use the delay behavior alone. To illustrate, we use the delay behavior to force a 10 second wait before performing the interaction to successfully complete the step. The result looks like this:
The second example is about using the delay behavior within a behavior sequence for more complex timed effects. In this example the VR user cannot grab the box until the entire sequence has run at least once. That is, the box must first move from its original position to a predefined position and back again before it can be grabbed. Once the VR user grabs the box successfully, the steps are completed and confetti is raining from the top. The finished result looks like this:
In a third example, the Repeat and Wait for completion functions - two powerful features of the behavior sequence - add additional complexity. Now the box moves from one position to another until the VR user grabs the green box. As soon as the user grabs the box in VR, confetti rains down from above. This way, the movement of an object is visually highlighted while interacting with it. Again, this is the end result:
This Unity scene has an environment that contains a floor and a table. On the table there is also a green box. We used basic Unity boxes for simplicity but VR Builder works with any 3D models as well.
The workflow of our VR application looks as follows:
In this Unity scene the VR user must grab the green box. However, since there is a 10-second delay, the VR user cannot exit the step until the waiting time has elapsed. Only then can the condition be fulfilled and the step completed. If the VR user needs more time than the given delay time to grab the box, they stay in the same step until they grab the box and the condition is met.
To create the delay behavior, select the step in the Process Editor. Next, go to Step Inspector > Behaviors > Add Behavior > Utility > Delay.
Set the delay to 10 seconds.
Delay behavior is very powerful when combined with behavior sequences, as more complex user interactions are possible. To illustrate, let’s create a complex, timed movement. If you don't know what a behavior sequence is, we recommend checking out the tutorial on consecutive steps and behavior sequences. Note that in this example we must disable Repeat and enable Wait for completion is enabled.
Our sample sequence will do the following:
When the scene is now run in VR, the user cannot grab the box until the entire sequence has run at least once. That is, the box must first move from its original position to the right (Box Target 1) and back again (Box Target 2) before it can be grabbed. Once the VR user grabs the box successfully, the steps are completed and confetti is raining from the top.
The result in Unity looks like this:
Two more powerful functions for using the delay behavior in behavior sequences are the Repeat function and the Wait for completion function. If you are not familiar with these concepts, read the tutorial on creating consecutive steps with behavior sequences.
If you want the box to move continuously from one position to another, you can select the Repeat checkbox.
Also, if you want the VR user to be able to grab the box at any time and complete the steps of the VR app without having to wait for the box to complete all the behaviors of the behavior sequence, you need to uncheck the Wait for Completion check box.
Now the box moves from one position to another until the VR user grabs the green box. As soon as the user grabs the box in VR, confetti rains down from above. This way, the movement of an object is visually highlighted while interacting with it.
In this VR Builder tutorial, you learned to delay user interaction by implementing the delay behavior. What if you want to validate if the VR user acts fast enough? Check out the tutorial on the timeout condition!