Conditional Logic Event

With Conditional Logic, you can trigger actions based on conditions: distance, value comparisons, or state changes. That way, creating more immersive experiences that react to the object’s input is possible, like a door opening when a character approaches using Game Controls.

Adding a Conditional Logic Event

Here’s how to add a Conditional Logic event to your scene:

  1. Select the object to that you want to add a conditional event.
  2. Add a new event on the Events Panel and select Conditional Logic.
  3. Open the Conditional Logic event to start adding and tweaking actions and parameters.
Adding a Conditional Logic Event.

Understanding Conditional Logic Events

Conditional Logic events are based on the “IfThen / Else” expressions to trigger actions based on the conditions mentioned earlier.

Conditions: if

The conditions refer to the statements that are defined and execute actions if the statements are met. The conditions available in Conditional Logic events are the following:

  • Distance: Measure the distance between objects in units. If the distance is met, the action will trigger.
Distance Condition.
Distance Condition.

  • State Change: Detect if an object changes to a specific state to trigger an action in the same or another object.
State Change Condition.
State Change Condition.

When the condition is true: then

If the condition is met an action is triggered. In Conditional Logic events, actions are based on transitions and sound.

Transitions can target objects and trigger a state change with transitions, delay, cycle, and loop properties. Sound actions can play, pause, and stop sounds from Spline’s Original Sounds Library or your own custom sounds.

To better understand how events work, go to Current Events, Events & Interactivity, and Play Sound Events.
Then actions.

A Super or Super Team subscription is needed to access Spline’s Original Sounds Library.

When the condition is false: else

If the condition isn’t met, another action can be triggered. Same as with then, else actions are based on transitions and sound.

Else actions.

Adding a Comparison Condition

Select Comparison under If to add the condition, then, select the object to compare, as well as what is going to be compared, position, scale, or rotation values, and on what axis, x, y, or z. Alternatively, you can select Object Parameter and define what values to create a comparison between objects.

After, select how to measure the comparison values, and finally type the value.

The then action will be triggered if the condition is met. An else action can be added if the condition isn’t met.

In this example, the position of the Pig character on the Z axis is measured to trigger an action, in this case, turning on the fan. If the condition isn’t met, the fan returns to its base state.

Adding a Distance Condition

Select Distance under If to add the condition, then, select the objects to measure the distance of and finally type the distance value.

If the distance is reached from object A to B, the then action will be triggered. An else action can be added if the condition isn’t met.

In this example, the distance between the Pig and the door is measured, when the Pig reaches the defined distance, the door opens. An else action is set up for when the Pig goes away the door is closed again.

Adding a State Change Condition

Select State Change under If to add the condition, then, select the object to detect the state change from, and finally select what state to detect.

If the State Change is detected from the selected object, the then action will be triggered. An else action can be added if the condition isn’t met.

In this example, a distance condition is used between the Pig and the chair to trigger a state change of the chair. That state change is detected by the TV in a State Change condition for it to turn on.

Preview the conditional logic event

You can preview the logic of the Conditional event at the top of the event panel. This can help to better understand the logic and the actions that will be triggered under the selected condition.


Try the experience 👇

You can mix Conditional Logic events with Game Controls and Physics to create immersive experiences. Try it out below!

Use W S A D keys to move the character, SPACE to jump, and ↑↓←→ keys to move the camera.

👉 Next Steps

Collision Event