> For the complete documentation index, see [llms.txt](https://obvious-game.gitbook.io/soap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://obvious-game.gitbook.io/soap/soap-core-assets/scriptable-variable/variable-reference.md).

# Variable Reference

Scriptable Variable

Instead of exposing a reference to a ScriptableVariable, you can use a Variable Reference:

```csharp
public class MyCustomClass : MonoBehaviour
{
    [SerializeField] private FloatReference _floatReference;
}
```

A variable reference allows you to choose between a local value or a ScriptableVariable.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf8bNS1BP6Y_N2rLoH2WFC7I6YfPhRmmetTS5b_6oxe7Hy8LbJpMwWHiW8RX6lXPRmquQCjMy2tvQoFSqOvYbj4lGhF0oKSJTEBpYMXqQsiGQbH61kMVPoZbGYwr69XTx61gCYES87coytNI47FmoazvLE?key=N4RcKQrHpqe_tYkdKbHJhg" alt="" width="563"><figcaption></figcaption></figure>

You might want to use a VariableReference instead of a ScriptableVariable when you aren't sure if you will want to use a ScriptableVariable for a specific variable.&#x20;

For example, I have a script called Car.cs and I want to expose the speed float variable. I'm not sure yet if I want to use a FloatVariable or just a float. Therefore, I can expose a FloatReference. Then in the inspector, if I choose 'Use Local', I can input a value as if it were a normal float. If later I want to access/modify the speed from other classes, I can create a FloatVariable called float\_speed, change to 'Use Variable' in the Car component from the inspector, and drag my new FloatVariable.

This can also be useful if you have multiple objects that share the same components. Let’s say you have different cars that share the same Car.cs component. Each AI car can use 'Use Local' with a predefined value, while the player car can 'Use Variable' and have it linked to a FloatVariable, making it flexible.

<br>
