Skip to content

Commit 7feb298

Browse files
Merge pull request #95 from PaulNonatomic/main
Develop
2 parents a750f9b + 60f44be commit 7feb298

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,25 @@ To install Visual State Machine in your Unity project, follow these steps:
2020
1. Create a state machine asset from the project panel. Right click -> Create -> State Machine -> State Machine
2121
2. Either right click and select "Add State" or drag out from the Entry State
2222

23-
![Unity_EQDqu8DdM8](https://github.com/PaulNonatomic/VisualStateMachineV2/assets/4581647/b8d9f18e-d168-49c1-9e02-f0df852ba086)
23+
https://github.com/user-attachments/assets/ff8fb491-fc7a-4658-8ee0-de0ddb2e8c0b
2424

2525
3. The State Selection window appears listing all available states.
2626
- States are grouped by namespace with the inbuilt states appearing at the top.
2727
- The group of states nearest to the location of the state machine asset will open by default but all states remain accessible.
2828

29-
![Unity_X0jYSx6JRS](https://github.com/PaulNonatomic/VisualStateMachineV2/assets/4581647/4eadac81-df9d-4793-943b-144a704d409a)
29+
![Unity_QcTKNF3bSr](https://github.com/user-attachments/assets/05eb3410-81ef-4085-860c-d95683d24b8b)
3030

3131
4. Create a custom state. Here's the built in DelayState as an example.
3232
- Add a Transition attribute to an exposed event Action in order for it to appear upon the states node in the State Machine Editor
3333
- Serialized and public properties are also exposed in the states node in the State Machine Editor. Note fields should be populated with value types and assets and not scene types.
3434

3535
```cs
36-
[NodeWidth(width:190), NodeColor(NodeColor.Teal), NodeIcon(NodeIcon.V2_Clock)]
37-
public class DelayState : State
36+
[NodeWidth(width:190), NodeColor(NodeColor.Teal), NodeIcon(NodeIcon.Clock)]
37+
public class DelayState : BaseDelayState
3838
{
39-
[Transition]
39+
[Transition(frameDelay:0)]
4040
public event Action OnComplete;
4141

42-
[SerializeField, Tooltip("Duration in seconds")]
43-
public float Duration = 1f;
44-
4542
[NonSerialized]
4643
private float _elapsedTime;
4744

@@ -53,16 +50,14 @@ public class DelayState : State
5350
public override void OnUpdateState()
5451
{
5552
_elapsedTime += Time.deltaTime;
56-
57-
if (_elapsedTime >= Duration)
58-
{
59-
OnComplete?.Invoke();
60-
}
53+
54+
if (_elapsedTime < Duration) return;
55+
OnComplete?.Invoke();
6156
}
6257

6358
public override void OnExitState()
6459
{
65-
60+
//...
6661
}
6762
}
6863
```
@@ -73,7 +68,7 @@ public class DelayState : State
7368
## Loops with Jump Nodes
7469
Add JumpOutState state and set it's Id. Then create a JumpInState with the corresponding Id to jump from one node to another.
7570

76-
https://github.com/PaulNonatomic/VisualStateMachineV2/assets/4581647/17fbb675-1a77-4117-bd2b-1c0f9c3e79a5
71+
https://github.com/user-attachments/assets/35715234-e532-464b-9031-4b7780efd3ef
7772

7873
## Transition Delay
7974
The process of transitioning between nodes originally incurred no delay at all but when wiring up a looping state machine

0 commit comments

Comments
 (0)