# Float

## Float cast nodes

You can use a float cast node to convert a float value to an integer or a string.

{% hint style="info" %}
The `Float To Int` node rounds down to the nearest whole number.
{% endhint %}

<figure><img src="https://2640392766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5yxYHsXtlAaoMUrDWhLm%2Fuploads%2Fgit-blob-6ee9e0ec1043dfd5c84c142afdd93653b73dde3e%2Fafx_node_float_cast.png?alt=media" alt=""><figcaption><p>Float cast nodes</p></figcaption></figure>

**Inputs:**

<table><thead><tr><th width="162">Name</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td>Input</td><td>Float</td><td>The value to be converted.</td></tr></tbody></table>

**Outputs:**

<table><thead><tr><th width="163">Name</th><th width="169">Type</th><th>Description</th></tr></thead><tbody><tr><td>Output</td><td>&#x3C;varies> [editable]</td><td>The converted value.<br><br>The output depends on the chosen node, and is either an integer or a string.</td></tr></tbody></table>

## Logic Float Changed

Outputs `true` in the frame where the input value changes.

**Inputs:**

<table><thead><tr><th width="152">Name</th><th width="160">Type</th><th>Description</th></tr></thead><tbody><tr><td>Input</td><td>Float</td><td>The float value to monitor.</td></tr></tbody></table>

**Outputs:**

<table><thead><tr><th width="155">Name</th><th width="159">Type</th><th>Description</th></tr></thead><tbody><tr><td>Output</td><td>Boolean</td><td>True when the <code>Input</code> changes, but resets to false at the end of the frame.</td></tr></tbody></table>

## Float Constant

Outputs a float value. An AFX graph cannot change the value of this node.

{% hint style="info" %}
You can open an AFX graph to change the value of this node in the Unity Editor.
{% endhint %}

**Outputs:**

<table><thead><tr><th width="153">Name</th><th width="172">Type</th><th>Description</th></tr></thead><tbody><tr><td>Output</td><td>Float [editable]</td><td>A floating point number.</td></tr></tbody></table>

## Generate Random Float

Generates a random number between Min and Max values, inclusive. For more information, refer to [Random.Range](https://docs.unity3d.com/2021.3/Documentation/ScriptReference/Random.Range.html) in the Unity documentation.

**Inputs:**

<table><thead><tr><th width="154">Name</th><th width="170">Type</th><th>Description</th></tr></thead><tbody><tr><td>Enter</td><td>Flow</td><td>Flow to activate the node.</td></tr><tr><td>Min</td><td>Float [editable]</td><td>The minimum value for the randomly generated number.</td></tr><tr><td>Max</td><td>Float [editable]</td><td>The maximum value for the randomly generated number.</td></tr></tbody></table>

**Outputs:**

<table><thead><tr><th width="154">Name</th><th width="170">Type</th><th>Description</th></tr></thead><tbody><tr><td>Exit</td><td>Flow</td><td>Continue the activating flow.</td></tr><tr><td>Output</td><td>Float</td><td>The randomly generated number.</td></tr></tbody></table>

## Get Float

Converts a reference to a float component to a float value.

**Inputs:**

<table><thead><tr><th width="182">Name</th><th width="166">Type</th><th>Description</th></tr></thead><tbody><tr><td>Float Component</td><td>Float Component</td><td>Reference to a float component.</td></tr></tbody></table>

**Outputs:**

<table><thead><tr><th width="176">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td>Output</td><td>Float</td><td>The value of the float component.</td></tr></tbody></table>

## Invert Float

Inverts a float value. Essentially changes the sign of the float from positive to negative or from negative to positive.

**Inputs:**

<table><thead><tr><th width="159">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td>Input</td><td>Float</td><td>The value to be inverted.</td></tr></tbody></table>

**Outputs:**

<table><thead><tr><th width="159">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td>Output</td><td>Float</td><td>The inverted value of the <code>Input</code>.</td></tr></tbody></table>

## Set Float

Set the value of a float object when activated by a flow.

<figure><img src="https://2640392766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5yxYHsXtlAaoMUrDWhLm%2Fuploads%2Fgit-blob-2edd07a238cfd22a4f5ed9ac7eb2be99caf02d66%2Fafx_node_set_float.png?alt=media" alt=""><figcaption></figcaption></figure>

**Inputs:**

<table><thead><tr><th width="199">Name</th><th width="172">Type</th><th>Description</th></tr></thead><tbody><tr><td>Enter</td><td>Flow</td><td>Flow to activate the node</td></tr><tr><td>Float Component</td><td>Object</td><td>Reference to the float object for which the value will be set.</td></tr><tr><td>Value In</td><td>Float [editable]</td><td>The value to be applied to the Float Component. Either the value provided to the input port or the value set in the field.</td></tr></tbody></table>

**Outputs:**

<table><thead><tr><th width="201">Name</th><th width="172">Type</th><th>Description</th></tr></thead><tbody><tr><td>Exit</td><td>Flow</td><td>Continue the activating flow.</td></tr><tr><td>Output</td><td>Float</td><td>Either the value provided to the Value In input port or the value set in the field.</td></tr></tbody></table>
