Zoe - Conditions and Actions
Tutorial
·
Beginner
·
+10XP
·
5 mins
·
(24)
Unity Technologies

Now you will learn to use conditions in order to trigger actions.
Languages available:
1. About conditions
As mentioned previously an 'Interaction' triggers actions when given conditions have been met. In the previous tutorial there were no specified conditions other than the delay from the beginning of the scene.
We are now going to see how to use conditions. Conditions are events happening in the scene, either because of the user’s actions or because of the interaction between objects. Zoe has several conditions already set, available through the 'ADD CONDITION' list inside every interaction. You can detect when an object has collided with another, when it is close to another, when the user has looked at an object, has touched it, grabbed it etc.

Condition list
Once a condition is met the action(s) trigger(s).
2. The Touch Condition
In this activity we are going to launch the Space Shuttle to the moon when touching the red button on the stand. Expand 'Activity4', select the ButtonTop and convert it into an Interactive Object.
Duplicate the Empty interaction and create a new one called ‘LaunchSpaceShuttle’. Add the Touch Condition from the 'ADD CONDITION' drop down list. Choose ‘Either’ hands and leave the mode to ‘Touch’. Under Target Objects you can see the ButtonTop(IO) already set:
Touch condition
3. The Translate action
Now let’s add the action. Inside the same interaction go to the ADD ACTION drop-down list and select ‘Translate’. A translation transformation will move an object from its current position to a new one.
Under ‘Objects To Move’ drag the Shuttle. Under destination drag the Moon (which is placed high in the sky).
We then need to set an offset value which means to set a distance from the center of the destination point to the actual position at which the object will stop, otherwise it will collide with it. Set 50 meters. Then set 60 seconds for the duration to reach the destination or another value depending on the speed you want the shuttle to have.
Shuttle translation animation
Press 'Play' and test the interaction. Adjust values if necessary.