Updated on
May 2, 2024
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 function - 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.
First, we set up the workflow in VR Builder 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 first to better understand what comes next. Note that "repeat" is disabled and "wait for completion" is enabled in this example. Will we explain these in the next section in detail.
Our example 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 before continuing here.
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 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 our Unity tutorial on the timeout condition!