Add docs section on pre change transformer in the variables tutorial

This commit is contained in:
Adam Ramberg 2023-07-20 23:30:27 +02:00
parent 3373862642
commit 02a13db7c5
4 changed files with 13 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -11,6 +11,6 @@ There are several ways of creating Atoms in your project. The recommended way is
![creating-atoms](../assets/creating-atoms/atoms-creation.gif)
Another way to create Atoms is to select `Unity Atoms` in the context menu. The items are listed by category and by type. Custom Atom types created using the `Generator` (introduced by a later tutorial) also appear in this menu.
Another way to create Atoms is to select `Unity Atoms` in the context menu. The items are listed by category and by type. Custom Atom types created using the `Generator` also appear in this menu (see the dedicated [generator tutorial](./generator.md) for more info on the generator).
In the following tutorials this is simply referred to as "creating an Atom" using any of the above mentioned techniques.

View File

@ -87,6 +87,18 @@ The `Developer Description` is a text describing the Variable in order to docume
`Changed` and `Changed With History` are explained in the [Events](./events.md) tutorial.
## Clamp health changes
Before we continue we can create a pre change transformer to clamp the `Health` between 0 and the value of `MaxHealth`. Go ahead and create an `ClampInt` function and rename it `ClampHealth`. Set min to 0 and max to `MaxHealth`.
![clamp-health](../assets/variables/clamp-health.png)
Add it as a pre change transformer to the `Health` variable:
![int-variable_clamp-health](../assets/variables/int-variable_clamp-health.png)
The value of `Health` will now be clamped between 0 and the value of `MaxHealth`.
## Assigning Atoms
Atoms can be assigned using the Unity Inspector. Assign the Atoms on the `PlayerHealth` like this: