mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-21 23:58:49 -05:00
Add docs section on pre change transformer in the variables tutorial
This commit is contained in:
parent
3373862642
commit
02a13db7c5
BIN
docs/assets/variables/clamp-health.png
Normal file
BIN
docs/assets/variables/clamp-health.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
BIN
docs/assets/variables/int-variable_clamp-health.png
Normal file
BIN
docs/assets/variables/int-variable_clamp-health.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
@ -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.
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user