> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spline.design/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Variable Action

Set Variable Action can update the value of a variable defined by an expression. The expression can reference another variable or variable helpers.

<Info>Learn more about [Variables](/interaction-states-events-and-actions/variables) to fully understand how to use Set Variable Action.</Info>

## How to use Set Variable Action

When an Event is performed, a variable can be set to a new value in the Set Variable Action by an expression – it can be either updated to another variable or a custom calculation. Following Events have access to Set Variable Action.

Learn how to use Set Variable Action through how-to steps in the [Variables](/interaction-states-events-and-actions/variables) doc.

## Events supporting Set Variable Action

When an Event is performed, a variable can be set to a new value in the Set Variable Action by an expression – it can be either updated to another variable or a custom calculation. Following Events have access to Set Variable Action

[Variable Change Event](/interaction-states-events-and-actions/events/variable-change-event)

[Start Event](/interaction-states-events-and-actions/events/start-event)

[Mouse Up Event](/interaction-states-events-and-actions/events/mouse-up-event)

[Mouse Down Event](/interaction-states-events-and-actions/events/mouse-down-event)

[Mouse Hover Event](/interaction-states-events-and-actions/events/mouse-hover-event)

[Key Up Event](/interaction-states-events-and-actions/events/key-up-event)

[Key Down Event](/interaction-states-events-and-actions/events/key-down-event)

[Key Press Event](/interaction-states-events-and-actions/events/key-press-event)

[Scroll Event](/interaction-states-events-and-actions/events/scroll-event)

[Drag and Drop Event](/interaction-states-events-and-actions/events/drag-and-drop-event)

[Distance Event](/interaction-states-events-and-actions/events/distance-event)

[State Change Event](/interaction-states-events-and-actions/events/state-change-event)

[Collision Event](/interaction-states-events-and-actions/events/collision-event)

[Trigger Area Event](/interaction-states-events-and-actions/events/trigger-area-event)

## Set Variable Action properties

### Select Variable

Select the variable to be updated via the Set Variable Action. The dropdown list will access any variables that are available on the current file.

### Add Expression

Create an expression to which the selected variable should be updated.

The following variable types can be used:

| **Variable type**              | **Defined by**                                                                                                                                               | **Usage**                                                                                                                                                     |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **🤹 Variables**               | Number, String, Boolean, Timers, Counter or Random                                                                                                           | Variables can store values that are reusable. For detailed explanation read the [Variables](https://docs.spline.design/d17e9b49f5284f19b309fce92af0d011) doc. |
| **ℹ️ Object Property**         | Object’s position, rotation, or scale (X, Y, Z), or it’s width, height and depth as a number, e.g.: `100`                                                    | Capture object property changes, and save them as variables to create advanced interactions.                                                                  |
| **🖱️ Mouse Position (2D)**    | The position of the mouse on the screen is defined by X and Y as numbers.                                                                                    | Animate or manipulate objects based on the mouse position                                                                                                     |
| **💥 Mouse Hit Position (3D)** | The position of the mouse hitting an object in 3D space, as Position X, Y, or Z of the hit location, or the Position X, Y, and Z of the object that was hit. | Create interactions based on specific hit positions, e.g.: visualize hit in 3D space.                                                                         |

The following math operations can be used in formulas:

| **Symbol** | **Operator**                        |
| ---------- | ----------------------------------- |
| `+`        | Add                                 |
| `-`        | Subtract                            |
| `*`        | Multiply                            |
| `/`        | Divide                              |
| `Random`   | Random value                        |
| `(` `)`    | Group calculations with parenthesis |

Some example formulas to spark ideas

* Variable A + Variable B
* Variable A \* 10 / 2
* (Variable A + Variable B) \* 10

***

## Using Set Variable Action with Conditional Action

[Conditional Action](/interaction-states-events-and-actions/actions/conditional-action) allows you to create more sophisticated Set Variable Actions. Read the doc to learn more about it.
