Inspiaaa / UnityHFSM

A simple yet powerful class-based hierarchical finite state machine for Unity
MIT License
1.14k stars 125 forks source link

[Feature Request] States that use tasks instead of Coroutines #45

Open TdXYZ opened 6 months ago

TdXYZ commented 6 months ago

Starting from Unity 2023.1, there is now an Awaitable class that makes it possible to use async/await functionality. It may be beneficial to add a sort of TaskState as an alternative to the CoState, as TaskStates could get around some of the limitations such as not being able to use lambdas,

Inspiaaa commented 6 months ago

Hi @TdXYZ, thanks for the feature request!

I didn't know about the Awaitable feature in the latest versions of Unity. Your proposal to have a new state class that works with Awaitable is a good idea! As I'm quite close to releasing version 2.1, I'll implement it in the next version of UnityHFSM. By using C# preprocessor directives, I intend to stay compatible with older versions of Unity while also supporting the latest features. I'll keep this issue open until I have implemented it.