UE4 Troubleshooting Crashes

by on

It's been a while since the last post, but today I ran into something strange.

I had implemented a custom movement that worked fine in the previous version of Unreal Engine 4, however, in version 4.22.3 it seems to have broken.

So, switched back to the multiplayer project we're working on, and I can't seem to play with the client as a listen server.

Constant crashes, which was puzzling, spent a couple of hours of the day trying to figure out why this is happening to me.

My mind started to wander. Maybe you need to set up the client to act as a server now? Why is the server calling client functions?

The culprit was this bit of code:

FNetworkPredictionData_Client* UCustomMovementComponent::GetPredictionData_Client() const
    check(CharacterOwner != NULL); 
    check(CharacterOwner->Role < ROLE_Authority );
    ... <snip>

CharacterOwner was PawnOwner at the time, this check was fine in previous engine versions, but now my game is crashing.

The solution was to just look at the engine implementation of the function, they use the following checks except checkSlow which I changed:


    check(CharacterOwner != NULL);
    check(CharacterOwner->Role < ROLE_Authority || (CharacterOwner->GetRemoteRole() == ROLE_AutonomousProxy && GetNetMode() == NM_ListenServer));
    check(GetNetMode() == NM_Client || GetNetMode() == NM_ListenServer);

If you're overriding a function that used to work and now doesn't and you're failing an authority role check, it seems that the listen server now also calls client implementation functions so check that first.

If you're wondering about the custom movement, I followed the wiki article here: https://wiki.unrealengine.com/Authoritative_Networked_Character_Movement

When creating ours, and it should be updated with the code above.

Lesson learned for the day before you go and try crazy nonsense check the engine implementation of the function you are overriding as a sanity check.

Comments 0
No comments have been left yet.