Btw, that warning doesn’t mean the State isn’t set.
That warning means that State doesn’t have generated functions for it on the “StateMachine” FSMBlueprint attached to PC_Bull_2.
When entering “OpeningCharge” State it calls “OnBeginOpeningCharge()” UFunction, but you didn’t create that one UFunction for the State to run.
After you add new States to the FSM Component Blueprint, hit “+Functions” on its details panel to generate missing UFunctions.
I changed it to Begin() and it’s still not being set for simulated proxies. The function runs just fine, aborted isn’t called, but the state name with debug still shows the old one.
In 1.8.5 Begin() was renamed Enter().
Not all the UFunctions, just this internal CPP “Begin()” has been renamed.
I set the Replication Mode to “None” (Replicates to Everyone) on FSM Component’s Details Panel; this way all Clients here receive OnREP_ calls when StateID changes.
For my latter test I had it set on an item’s begin play, at which point the state machine wasn’t initialized and as such the begin/exit doesn’t work until then, so even though it replicated it wasn’t setting the state.
Need a graceful workaround but I’ll think about it tomorrow
So… basically… I can’t solve it. I’ve already solved this issue previously for my items, but I can’t with the state machine.
The server has the state set correctly. The clients never do for anything that was set prior to the state machine’s initialization. I can even force their replication again after initialization and they still don’t receive the correct state.
I’m suspecting that whatever the issue is originates from this incredibly odd initialization routine. Why isn’t the state machine initialized following the completion of PostInitializeComponents? By the time BeginPlay is called it should have long since been initialized. It doesn’t make sense that a component isn’t fully initialized at that point and goes against UE4’s architecture.
Should be
Component Initializes
??
Begin Play
Is Actually
Begin Play
Replication occurs and nothing works because SM isn’t initialized
Component Initializes
I’ve been beating my head against the wall for hours and I don’t know how else to fix it because I’ve already implemented the fixes and they don’t work in this single case.
It is done this way because AnimBP syncing.
Since you apparently aren`t using that sync, I believe you can remove that logic from BeginPlay and place it where it fits your code:
As a heads up or for anyone reading over this, the code you provided here wasn’t resetting the state time, and I don’t need to replicate that since the state itself is being replicated so:
It just means it wasn’t checked to exist or not.
This “Unchecked” thing is there because there’s people adding/removing replicated States at game runtime…
But it shouldn’t do that for the startup, I will look tomorrow to see that is happening.
Would there be other people or replication in a non-multiplayer game?
Oh, got it. Somehow component auto-activate was unchecked. Probably from the plugin being disabled.
Back to the original issue:
PIE: Warning: {FSM}:: 'Set State' named [EAIState::NewEnumerator9]: State ID doesn't exist. --> FSM: Set State: [Function /Script/UFSM.StateMachineComponent:SetState at (StateMachineComponent /Game/AvGaHo/Maps/UEDPIE_0_Map_Bull.Map_Bull:PersistentLevel.PC_Bull_2.StateMachine)]
FSMs: Warning: [StateMachine]: 'Set State' named [EAIState::NewEnumerator9]: State ID doesn't exist.
This is weird. My enum name isn’t “NewEnumerator9” and the type is right. I guess I’ll just store it as a name instead.
Hmm…
Are you comparing States to enum names??
Unreal internally names BP Enums like that: “enum::itemname”.
I wouldn’t compare States to bp enum names, weird things like that might happen; I’d only use them to “copy” States quickly into the States array, specially because the way Epic serializes BP Enums into assets (they aren’t real enums).
If you’re getting the “name” of a BP Enum item it will output something like that (the internal name of item) instead of the display name you see in Blueprint Graphs.
I just had a typed variable for the state and I was setting it with a dropdown. Then when I was setting the state it was converting it into a name, so yeah probably. Normally that conversion works but I guess there’s a UE limitation in there.
This occurred again. Last time the only way I could fix it was by rebuilding the state machine from scratch (which isn’t happening so I need a solution). Somewhere it has corrupted. I try to delete it and remake the specific state but the issue persists. Now whenever the state is set to 1 it crashes.
State object in TMap index 1 for some reason is null.
How are you creating States list?
Somewhere in the process index 1 is ignored when you create them.
Btw, you can force State creation with:
StateMachine->AddState(1,FName("stateName"));
But I’d rather examine Blueprints and identify why this one in particular isn’t being created in your setup…
You may have duplicate State names or related issue; now that TSet is supported by Blueprints I should convert name list from Array to Set, but that deprecation process is annoying so I may only do that for 2.0+ version on Unreal 4.20+.
I could construct an exact duplicate of this state machine from scratch and it will work. That’s how I fixed it last time. Feels like something is corrupting internally.
I’m creating the states by simply adding to the array. I made an enum and provided that instead but no difference.
https://i.imgur.com/MTN3lX1.png
On an unrelated note since you mention 2.0 can I make a suggestion/request?
In the screenshot provided for the issue, you can see that some states are actually transitions, eg. “Equipped” is a state and “Equipping” is a transition; during “Equipping” state there is an animation playing, a sound, a material effect and when the duration expires it goes to Equipped.
And then the “FSM Default Links” already has a state that it transitions to when Finish State is called. For transitions that can go one way or the other, they’d need a BlueprintNativeEvent that takes the next state as an argument.
So basically, the idea is that the FSM Default Links could also have a ‘Duration’ set, when the Duration expires it transitions to the NextState. Furthermore, these could have a BlueprintImplementableEvent (or native if needed) that return the next state to transition to - so for example my “PickingUp” state is a transition that either goes to “Equipping” (if it can be equipped and nothing is equipped there) or “Unequipped” (in inventory), in which case I’d check it’s destination in that function and return the “Equipping” or “Unequipped” state based on that.
If this does happen, it might be worth having an interrupted call back, if finish state or begin state was called part way through a transition. Also, when starting a state or transition from an interrupted transition it could be worth having the left-over time.