Announcement

Collapse
No announcement yet.

UFSM: Finite State Machine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    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.

    Leave a comment:


  • replied
    I finally got the plugin update installed.

    I'm getting a new issue - the startup state is being ignored and it's just using the first state in the enum.

    If I force the state on BeginPlay it returns "unchecked". What does this result actually mean? There's nothing in the output panel.

    Leave a comment:


  • replied
    Originally posted by BrUnO XaVIeR View Post
    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:
    Code:
    FSM_Transition Transition;
    MakeStates(STATES,Transition);
    
    InitializeFSM();
    You can call that sequence anywhere needed. It's placed there in BeginPlay because, again, AnimBP State syncing.
    Thank you so much! Working all round now.

    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:

    Code:
    void UStateMachineComponent::OnREP_StateID_Implementation(uint8 &ID)
    {
        ID = StateID;
    
        FSM_Transition Transition = FSM_Transition::Succeeded;
        Exit(PreviousStateID, ID, Transition, InExit);
        Enter(ID, InBegin);
        StateTime = 0.f;
    
        if (Transition != FSM_Transition::Succeeded)
        {
            LOG_PIE(Debug, ESeverity::Warning, this, FFIND(TEXT("OnREP_StateID")), FString("[OnREP_StateID]: Exiting 'PreviousStateID' was aborted."));
        }
    }

    Leave a comment:


  • replied
    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:
    Code:
    FSM_Transition Transition;
    MakeStates(STATES,Transition);
    
    InitializeFSM();
    You can call that sequence anywhere needed. It's placed there in BeginPlay because, again, AnimBP State syncing.

    Leave a comment:


  • replied
    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
    1. Component Initializes
    2. ??
    3. Begin Play

    Is Actually
    1. Begin Play
    2. Replication occurs and nothing works because SM isn't initialized
    3. 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.
    Last edited by Vaei; 06-23-2018, 07:17 PM.

    Leave a comment:


  • replied
    You can use "OnInitialized" event on the FSM Component instead of Begin Play.

    Leave a comment:


  • replied
    Originally posted by BrUnO XaVIeR View Post

    In 1.8.5 Begin() was renamed Enter().
    Not all the public 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.
    Thanks so much for your assistance.

    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

    Leave a comment:


  • replied
    Originally posted by Vaei View Post
    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 public 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.

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    Originally posted by BrUnO XaVIeR View Post
    Vaei I have fixed that problem here in my Component doing these changes to the native OnREP_ functions:

    Code:
    void UStateMachineComponent::OnREP_StateID_Implementation(uint8 &ID) {
    
    ID = StateID;
    
    FSM_Transition Transition = FSM_Transition::Succeeded;
    Exit(PreviousStateID,ID,Transition,InExit);
    Enter(ID,InBegin);
    
    if ( Transition != FSM_Transition::Succeeded ) {
    LOG_PIE(Debug,ESeverity::Warning,this,FFIND(TEXT("OnREP_StateID")),FString("[OnREP_StateID]: Exiting 'PreviousStateID' was aborted."));
    }
    
    }
    
    void UStateMachineComponent::OnREP_StateTime_Implementation(float &Time) {
    Time = StateTime;
    }
    
    void UStateMachineComponent::OnREP_PreviousStateID_Implementation(uint8 &PreviousID) {
    PreviousID = PreviousStateID;
    }
    Doing that instantly fixed here all my Components containing overriden OnREP_StateID function.
    Thank you!

    But did you mean to use Begin() and not Enter()? Enter() doesn't exist

    Leave a comment:


  • replied
    I'm not using those functions, it's just that it was the only output. I guess I definitely don't have the update then.

    Leave a comment:


  • replied
    Weird. Here the update is marked as processed.

    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.
    Last edited by BrUnO XaVIeR; 06-22-2018, 10:18 AM.

    Leave a comment:


  • replied
    Are you sure Epic have released the update? I've been restarting the launcher but I'm yet to see an update to the plugin come through.

    To be double sure I enabled debug and I'm trying to get some info out. The state I'm trying to set isn't showing up as failed (or at all). So far all I see is normal looking stuff:

    Code:
    PIE: Warning: {FSM}:: ''Blueprint Auto Flow FSM'' is enabled; Trying to invoke ''On Begin'' for (OpeningCharge) State, but (OnBeginOpeningCharge) function have not been found! -->  Begin: [Function /Script/UFSM.StateMachineComponent:Begin at (StateMachineComponent /Game/AvGaHo/Maps/UEDPIE_0_Map_Bull.Map_Bull:PersistentLevel.PC_Bull_2.StateMachine)]
    PIE: Warning: {FSM}:: ''Blueprint Auto Flow FSM'' is enabled; Trying to invoke ''On Exit'' for (OpeningCharge) State, but (OnExitOpeningCharge) function have not been found! -->  Exit: [Function /Script/UFSM.StateMachineComponent:Exit at (StateMachineComponent /Game/AvGaHo/Maps/UEDPIE_0_Map_Bull.Map_Bull:PersistentLevel.PC_Bull_2.StateMachine)]
    PIE: Warning: {FSM}:: ''Blueprint Auto Flow FSM'' is enabled; Trying to invoke ''On Begin'' for (EmergencyStop) State, but (OnBeginEmergencyStop) function have not been found! -->  Begin: [Function /Script/UFSM.StateMachineComponent:Begin at (StateMachineComponent /Game/AvGaHo/Maps/UEDPIE_0_Map_Bull.Map_Bull:PersistentLevel.PC_Bull_2.StateMachine)]
    Maybe I'm doing something else wrong? I've set up a call to queue a future state, then when the current activity is finished it switches to that state:



    The execution chain is: it starts with OpeningCharge, has Stare set as the future state and then EmergencyStop executes when it reaches the edge of the play area. When it calls emergency stop it waits for a moment then calls the event to set the next state, which is when it aborts.
    Last edited by Antidamage; 06-22-2018, 08:53 AM.

    Leave a comment:


  • replied
    Vaei I have fixed that problem here in my Component doing these changes to the native OnREP_ functions:

    Code:
    void UStateMachineComponent::OnREP_StateID_Implementation(uint8 &ID) {
    
        ID = StateID;
    
        FSM_Transition Transition = FSM_Transition::Succeeded;
        Exit(PreviousStateID,ID,Transition,InExit);
        Enter(ID,InBegin);
    
        if ( Transition != FSM_Transition::Succeeded ) {
            LOG_PIE(Debug,ESeverity::Warning,this,FFIND(TEXT("OnREP_StateID")),FString("[OnREP_StateID]: Exiting 'PreviousStateID' was aborted."));
        }
    
    }
    
    void UStateMachineComponent::OnREP_StateTime_Implementation(float &Time) {
        Time = StateTime;
    }
    
    void UStateMachineComponent::OnREP_PreviousStateID_Implementation(uint8 &PreviousID) {
        PreviousID = PreviousStateID;
    }
    Doing that instantly fixed here all my Components containing overriden OnREP_StateID function.

    Leave a comment:


  • replied
    Originally posted by Vaei View Post

    The 'Aborted' callback is the result when I do that
    I am testing this as well.
    Seems like the OnREP_StateID_Implementation has a bug when it is overriden by the GeneratedClass.

    I will see if I can fix that by manually adding Exit(PreviousID) then call Enter(StateID) from within the native C++ OnREP_ function instead;
    That may resolve the issue.

    Leave a comment:

Working...
X