Finite State Machine

Is there an example code showing how to implement Finite State Machine in playcanvas?

I don’t know of a “proper” finite state machine in PlayCanvas. Most of the games that use a UI have some kind of simple state system. But I wouldn’t go as far as call them an FSM.

A simple state system will do as well. Is there an advantage to using some kind of state system in playcanvas or does playcanvas already have something similar?

There’s nothing built into the engine. That sort of thing is pretty high-level to your game. I don’t think we would want to include that in the core API.

I’ve been using this one in a professional project.

There’s loads more on github, if you don’t like the author’s approach.

Thanks josepedrodias, these looks good but I managed to implement a simple one in the end that fits my current scenario. :smiley:

This might look like a necropost… but Im viewing this same state machine… yet when I import the code into the project its not recognized because it id not a playcanvas entity script… How did you modify it or wrap it so you can use it? thanks

It’s easy to use it in your project. Just do this: