GC FSM - Event-driven, hierarchical finite state machines in blueprint

Thx for replying. :slight_smile:
In C++, it is easy to create an FSM State class, but it seems there is no way to create a FSM class in C++. My project is mostly implemented by C++, so, it is a little complicated for me to use GC FSM in C++. But GC FSM is doing really good at Buleprints. Try to create a GC FSM in C++ is rare, so this may not be really needed.
An other suggestion, I can’t found the GC FSM C++ API reference docment. I try to read the head file to get the API’s Description. So, if GC FSM can provide the C++ API’s reference and Example Project, that will be perfect.
Final one is, Can GC FSM support “Any State”? Just like the FSM in Unity3D, For example, I made a FSM, it had many states, in every state, if it triggered by event “Cast Spell Failed”, it will trans to the “Idle” state, It’s trouble to add one same event to all the states. So, if FSM support “Any State”, It would be a greate help.

Thx for reading. :slight_smile:

I agree that the C++ interface should be better documented. I’m adding the task to my TODO list.

As for having an FSM written in C++, I am really sorry, but that is not going to happen. The main goal of GC FSM is to allow you to write FSMs in blueprints, therefore an FSM is a blueprint function. There’s no concept of FSM class, in fact the class UGCFSM is not meant to be sub-classable. Each state node is implemented with a latent function, so that the blueprint execution can be stopped when the state is entered and resumed when the state is exited. This mechanism is the core of GC FSM. Writing an FSMs in C++ would either require to implement a totally different paradigm or to be able to write coroutines in C++. (This might actually be considered, since VS2017 already supports C++ coroutines in c++17 mode, so at least the PC platform would be covered, However we still have to wait for Unreal to change theirs scripts to allow c++17 builds.)

As for the “Any State” idea, I might consider that. Howerer, please notice that you can already achieve the same result by using a sub-FSM, where the “Cast Spell Failed” event is handled in a higher level of the FSM hierarchy. I’m currently working on a new kind of state node that will make this design approach much easier to implement and maintain. It will be included in the next release.

Got it. Glad to see that the next release will be more powerful :D:D:D:D :cool::cool::cool::cool:

Hello, I’m TX_loser who reply you on the marketplace. I’m sorry to take up your time, could answer me what “game functions and play” needs to use this plug-in? emmm,my enligsh not good, I hope you understand

Hey GC, first of all, I’ve been loving the ability to rewrite my AI logic using this plugin, but I’m coming across a bizarre issue: when running in editor, everything works fine, but when I attempt to run in standalone, the FSM never activates. On BeginPlay, it’s set to use LaunchFSM to trigger my actor’s first state, but it never actually executes that command. I tried placing a print after the LaunchFSM function in the actor BP just to see if the print would fire after the LaunchFSM function when played in standalone. The print message never fires, meaning that the BP gets stuck in the middle of executing the LaunchFSM function, or something. Any ideas on what might be the issue?

Is network replication involved?

I am really sorry, but using this plugin requires previous knowledge of what a Finite State Machine is. It’s really hard for me to explain how the plugin works if the basic concepts are not well understood. The two links I already posted in a reply to your post on the marketplace contain brief introductions that you should definitely read. I have an example project on my website to show how to use the plugin in a game, but you need to buy the plugin first to use it. Although I may prepare a very basic tutorial about FSMs in general, you may have to wait a little, since it would take me a lot of time and at the moment I am working on fixing issues and implementing the new features for the next release.

No matter, you can at any time reply to me once you are free, I see the introduction of this plug-in and relate toBT, I have a certain understanding of BT, but the introduction of the plug-in interest me , maybe I have a better understanding of the game function and optimization by study and use your plugin.

So, is the 4.20 update broken? 'm pressing “install to engine” and absolutely nothing happens.

While the version v1.5.1 for Unreal 4.18 and 4.20 went online two days ago, as reported in the release thread, there was a technical issue on the Marketplace backend with the same version for Unreal 4.19. The issue has been solved a few hours ago and that version is now online, too.

I don’t know if that answers your problem, though. What is your situation and what are the operations that you are performing? In order to upgrade the plugin you typically do not click on “Install to Engine” but on the “Installed plugins” right below the engine instance.

The plugin is not showing up in the “installed plugins” window for 4.20, and as I said doing “install to engine” In the vault has no effect. The same is true when I try upgrading a 4.19 project and get the “this project requires plugin x, would like to download it from the marketplace?” dialogue. I’ll try reinstalling 4.20 and see if that fixes it.

Update: reinstalling 4.20 didn’t help.

As soon as the plugin went online, I had checked and were able to install the plugin on Unreal 4.20. However, I just tried again doing a clean install and now I can reproduce your problem: clicking on “install in engine” and selecting slot 4.20 doesn’t do anything. I am contacting the Marketplace team, hoping they can fix the issue and keep you informed.

I submitted a new version (v1.5.2) specifically for Unreal 4.20 and it went online just now. This appear to solve the issue that was reported earlier. Please let me know if you are still having problems with it. As a bonus, this new version supports the Mac and iOS platforms too! Hurray!

The new version installed correctly, thanks!

Where can one grab the 4.20 update? I’m not sure I see it on the marketplace.

Hi there, there seems to be a garbage collection bug / issue with how this plugin works with a dedicated server multiplayer (not replication).

Find sample project here: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

Steps to reproduce without sample project:

  1. Create game mode with a simple PING-PONG state machine that switches from ping to pong (etc) every 1s.
  2. Launch FSM in BeginPlay (note that it’s not intended to be a replicating FSM, just a local FSM to the server in the game mode)
  3. OnTick log out “FSM is running: {0} in State {1}”
  4. Launch dedicated server using a command (with your UE4 path and IP address) such as

"C:\Program Files\Epic Games\UE_4.20\Engine\Binaries\Win64\UE4Editor.exe" "%CD%\..\FSMTest.uproject" ThirdPersonExampleMap?listen -server -log -nosteam -port=1234


  1. Launch client to connect to server using a command such as

"C:\Program Files\Epic Games\UE_4.20\Engine\Binaries\Win64\UE4Editor.exe" "%CD%\..\FSMTest.uproject" 192.168.1.157:1234 -game -ResX=1280 -ResY=720 -WinX=0 -WinY=20 -log -nosteam -WINDOWED

After about 20 seconds the FSM context gets garbage collected and you see a transition in the server log that looks like:



[2018.08.11-19.45.33:584][807]LogBlueprintUserMessages: [ThirdPersonGameMode_C_0] FSM is running: 1 in State Ping
[2018.08.11-19.45.34:583][837]LogBlueprintUserMessages: [ThirdPersonGameMode_C_0] FSM is running: 1 in State Pong
[2018.08.11-19.45.34:627][838]LogGCFSM: Error: Object ThirdPersonGameMode_C_0 is not running FSMs
[2018.08.11-19.45.34:698][840]LogBlueprintUserMessages: [ThirdPersonGameMode_C_0] FSM is running: 0 in State


What you see above is that** GetContext() in the FSM is failing because the weak pointer starts pointing to NULL** about 20s after the first client connects.

Hi Emil,

thank you very much for taking the time to write this very detailed report. I am really sorry, but I am on vacation at the moment and can’t address issue promptly. I will have a look at it at the first opportunity, which is probably not sooner than the end of the next week.

Thanks again for your patience,

Have begun migrating my project to use this plugin, which has so far cleaned my spaghetti blueprints right up!

However, I’m unable to nativize any blueprints that contain a state machine. Note that the states themselves are able to be nativised, just not the blueprints handling them.

This is the error I receive when packaging:


UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(476): error C2248: 'UGCFSMState::MakeStateObject': cannot access private member declared in class 'UGCFSMState'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Source\../Plugins/Marketplace/GCFSM/Source/Runtime/Classes/GCFSMState.h(138): note: see declaration of 'UGCFSMState::MakeStateObject'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Intermediate\Build\Win64\UE4\Inc\NativizedAssets\BP_PlayerController__pf1547632563.generated.h(11): note: see declaration of 'UGCFSMState'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(488): error C2248: 'UGCFSM::EnterState': cannot access private member declared in class 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     c:\program files\epic games\ue_4.20\engine\plugins\marketplace\gcfsm\source\runtime\classes\GCFSM.h(74): note: see declaration of 'UGCFSM::EnterState'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Plugins\Marketplace\GCFSM\Intermediate\Build\Win64\UE4\Inc\GCFSM\GCFSMSubmachineState.generated.h(11): note: see declaration of 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(517): error C2248: 'UGCFSMState::MakeStateObject': cannot access private member declared in class 'UGCFSMState'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Source\../Plugins/Marketplace/GCFSM/Source/Runtime/Classes/GCFSMState.h(138): note: see declaration of 'UGCFSMState::MakeStateObject'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Intermediate\Build\Win64\UE4\Inc\NativizedAssets\BP_PlayerController__pf1547632563.generated.h(11): note: see declaration of 'UGCFSMState'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(530): error C2248: 'UGCFSM::EnterState': cannot access private member declared in class 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     c:\program files\epic games\ue_4.20\engine\plugins\marketplace\gcfsm\source\runtime\classes\GCFSM.h(74): note: see declaration of 'UGCFSM::EnterState'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Plugins\Marketplace\GCFSM\Intermediate\Build\Win64\UE4\Inc\GCFSM\GCFSMSubmachineState.generated.h(11): note: see declaration of 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(543): error C2248: 'UGCFSM::Stop': cannot access private member declared in class 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     c:\program files\epic games\ue_4.20\engine\plugins\marketplace\gcfsm\source\runtime\classes\GCFSM.h(77): note: see declaration of 'UGCFSM::Stop'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Plugins\Marketplace\GCFSM\Intermediate\Build\Win64\UE4\Inc\GCFSM\GCFSMSubmachineState.generated.h(11): note: see declaration of 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(552): error C2248: 'UGCFSM::ReplicationWaitFunction': cannot access private member declared in class 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     c:\program files\epic games\ue_4.20\engine\plugins\marketplace\gcfsm\source\runtime\classes\GCFSM.h(135): note: see declaration of 'UGCFSM::ReplicationWaitFunction'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Plugins\Marketplace\GCFSM\Intermediate\Build\Win64\UE4\Inc\GCFSM\GCFSMSubmachineState.generated.h(11): note: see declaration of 'UGCFSM'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Private\BP_PlayerController__pf1547632563.cpp(588): error C2248: 'UGCFSMState::MakeFSM': cannot access private member declared in class 'UGCFSMState'
UATHelper: Packaging (Windows (64-bit)):     C:\Program Files\Epic Games\UE_4.20\Engine\Source\../Plugins/Marketplace/GCFSM/Source/Runtime/Classes/GCFSMState.h(141): note: see declaration of 'UGCFSMState::MakeFSM'
UATHelper: Packaging (Windows (64-bit)):     D:\Projects\Framework\Intermediate\Plugins\NativizedAssets\Windows\Game\Intermediate\Build\Win64\UE4\Inc\NativizedAssets\BP_PlayerController__pf1547632563.generated.h(11): note: see declaration of 'UGCFSMState'

It doesn’t appear to matter what the state machine is doing. Even just a “Launch FSM” node will get that error.

Hi Albie_123, thanks for reporting. I have to admit that I didn’t test nativization throurougly, but I understand why it may be important to you. I will check that everything works correctly in the next release. According to your error log it might just be a matter of declaring some private function public. I’ll keep you posted.

I suspect that’s all it is as well. Either way, not a huge problem at this stage, happy to wait!