RNG Node
Overview
The Random Number Node, also known as RNG, generates a random number within a specified range. This node is useful for creating randomized behavior in your graph.
The node can be configured to generate either integers or floating-point numbers. The range of the random number can be specified with a minimum and maximum value. The maximum value can be set to be either inclusive or exclusive.
- Inputs
- Outputs
- Editor Settings
Inputs
Title | Data Type | Description | Default Value | Notes |
---|---|---|---|---|
Min | number | The minimum value of the random number. This input is only available if Use Min Input is enabled in the editor settings. | (optional) | The input will be coerced into a number if it is not a number. |
Max | number | The maximum value of the random number. This input is only available if Use Max Input is enabled in the editor settings. | (optional) | The input will be coerced into a number if it is not a number. |
Outputs
Title | Data Type | Description | Notes |
---|---|---|---|
Value | number | The generated random number. |
Editor Settings
Setting | Description | Default Value | Use Input Toggle | Input Data Type |
---|---|---|---|---|
Min | The minimum value of the random number. | 0 | Yes | number |
Max | The maximum value of the random number. | 1 | Yes | number |
Integers | If enabled, the node will generate integer numbers. If disabled, the node will generate floating-point numbers. | False | No | N/A |
Max Inclusive | If enabled, the maximum value will be inclusive. If disabled, the maximum value will be exclusive. | False | No | N/A |
Example 1: Generate a random integer
- Create a Random Number Node.
- Set the
Min
to1
and theMax
to10
. - Enable the
Integers
setting. - Run the graph. The output of the Random Number Node should be a random integer between 1 and 10.
Example 2: Generate a random floating-point number
- Create a Random Number Node.
- Set the
Min
to0
and theMax
to1
. - Disable the
Integers
setting. - Run the graph. The output of the Random Number Node should be a random floating-point number between 0 and 1.
Error Handling
The Random Number Node will error if the Min
is greater than the Max
. If the Min
and Max
are equal, the node will always output the Min
value.
FAQ
Q: Can I use the Random Number Node to generate a random boolean value?
A: Yes, you can use the Random Number Node to generate a random boolean value by setting the Min
to 0
, the Max
to 1
, and enabling the Integers
setting. The node will then output either 0
or 1
, which can be interpreted as false
and true
by a Bool Node.
Q: Can I use the Random Number Node to generate a random string?
A: No, the Random Number Node can only generate random numbers. If you want to generate a random string, you can use a Code Node with a custom JavaScript function.