Vizard 7 » Reference » Flow control » Actions » Action synchronization & management
7.6

Action synchronization & management

The vizact library comes with many synchronization actions. Synchronization actions allow you to freeze an objects action controller until a certain event occurs. These events could be key presses, expired time, or a signal event. Here is a simple example of fading an object out after the 'f' key is pressed:

wait = vizact.waitkey('f')
fade = vizact.fadeTo(0,begin=1,time=2) #Fade from opaque to transparent in 2 seconds
object.add(wait)
object.add(fade)

Another common synchronization action is to wait for a specified amount of time.

This sample code will fade an object in, wait 2 seconds, and fade it out:

wait = vizact.waittime(2)
fadeIn = vizact.fadeTo(1,begin=0,time=1)
fadeOut = vizact.fadeTo(0,begin=1,time=1)
object.add(fadeIn)
object.add(wait)
object.add(fadeOut)

However, let's say you wanted to synchronize actions of multiple objects. For instance, let's assume you already have the objects key and door, with actions turnkey and openDoor. What we want is to perform the openDoor action after the turnkey action is finished. Since these actions are performed on different objects we can't simply add one after the other. What we need in this case is a signal object. A signal object contains two actions. One that triggers the signal and one that waits for the signal. So, for this example we would trigger a signal after the turnkey action and wait for the signal before the openDoor action. Here is what the code would look like:

#Create the signal object
keySignal = vizact.signal()
key.add(turnKey) #Turn the key first
key.add(keySignal.trigger) #Trigger the event
door.add(keySignal.wait) #Wait for the event
door.add(openDoor) #Open the door

See also

In this section:

Action Basics

Sequences

Dynamic parameters

Node commands as actions

Creating your own actions

Actions command table

Other sections:

Tutorial: Using actions

Task basics

Director basics

Timer basics

Animation path basics

Event Basics

Event Reference

Example scripts:

Actions

Event callbacks