# Parallel Action¶

The ParallelAction is used to instantiate two or more Actions simultaneously. Then the user can decide which one to complete first.

Additionally, ParallelAction can modify the Scenegraph tree according to the user’s decisions. ParallelActions are usually linked with critical errors. For example, we may implement a ParallelAction which has a correct and a wrong Action to Perform. If the user decides to complete the correct Action, then the simulation will continue as usual. However, if the user completes the wrong Action (for instance inserting an object in a wrong place) then this behavior will trigger the alternative path and the scenegraph will be modified runtime by adding or removing specific Actions.

For instance, if the user causes damage to a human bone, the scenegraph will populate a new stage that forces the user to correct their mistake by repairing the fracture. In another example, if the user paints a car with the wrong color, the scenegraph can add new Actions in order to repaint it.

Note

Parallel actions can now be simulated directly inside the Live SceneGraph with the Sequence node

In this example, we will implement a ParallelAction where the user needs to decide whether to assemble the Knossos model or the Sponza model. This Action is part of the SampleApp level named AssembleKnossosORSponzaAction

Note

The “normal” path involves the assembly of Knossos and the “alternative” path the assembly of Sponza.

As a result, if the user decides to assemble the Knossos, the scenegraph will move to the next Action. However, if they assemble the Sponza, the scenario will change accordingly to accomodate the decision.

## SceneGraph Setup¶

Inside the SceneGraph (SceneGraph_SampleApp), we create a new boolean variable named “ChoseKnossos”. This will be set to true if the user chose to assemble the Knossos model, and false otherwise.

## Action Blueprint¶

The graph below implements the action:

### Blueprint Walk-through¶

Initially, the two actions which will determine the path are created and configured. They are both InsertActions, and are stored as temporary variables for use later on when the ParallelAction is set-up.

Next up, we configure the number of the alternative path that each action will trigger upon completion. In our example, the Assemble Knossos action will trigger the default path (making no change to the scene graph) which is -1. If the user chooses to assemble Sponza, it will trigger the alternative path 0

Finally, we implement the event “On Set Path”, and set the variable of “ChoseKnossos” depending on the path number:

### SceneGraph Configuration¶

The final part is to handle the actual logic after the action has been completed, from the Scene Graph:

In the image above, the action in the second stage of the Starting Lesson includes the class for our new parallel action. After this action is performed, the variable of “ChoseKnossos” will have a valid value depending on what the user chose to do.

### Parallel Action Explanation¶

Now let’s see what happens when we start the application. Move to the AssembleKnossosORSponzaAction Action that will set the “ChoseKnossos” variable. As you can see both Actions are Initialized simultaneously, the user should decide which one will complete. To trigger the alternative path we have to insert the Sponza model.

Upon performing the action by choosing to assemble Sponza, the variable of “ChoseKnossos” will be set to false, and the scene graph will spawn the actions relevant to Sponza.