Player animations slow down on listen server

I saw similar questions on this topic, but they did not help me get rid of lags in animation playback. I want to clarify that I use blueprints, do not use Event tick nodes and do not overload the game with unnecessary events. I use Advanced steam sessions to connect and no other plugins for anything else. I tried every method I could find on the Internet, but it did not help. I have not added or changed the binding to ticks or time anywhere before.

I found some patterns in lag playback to localize the problem, but I don’t understand how to fix it.
Here is a list of what I tracked:

  1. Animation is choppy and slow on the listen server. But clients see animations normally.
  2. If I set a fixed fps to 60, nothing happens. If I set it to 120 the animations slow down on ALL instances, but the animation slows down more on the server than on the clients. If I set 15 fps, then the game also starts to lag very much (motion lags and animation freezes)
  3. If I set smooth fps, then nothing changes.
  4. IMPORTANT: Animations lag ONLY in blueprints that players possessed(60fps). If I put the same player blueprint on stage it will play the animations normally EVEN on the listen server. Also on AI character animations work fine even on server. Also local animations in listen server player.
  5. Animations lag both with network lag emulation and in games on different PCs. When playing without delay, there are absolutely no lags.

What I have tried:

  1. Added to DefaultEngine.ini (no brackets):
    a) p.NetEnableMoveCombining=0. I honestly don’t know what it does, but I saw that someone advised it.
    b)ConfiguredInternetSpeed=500000, ConfiguredLanSpeed=500000, MaxClientRate=800000, MaxInternetClientRate=800000
    In DefaultGame.ini - TotalNetBandwidth=500000, MaxDynamicBandwidth=80000, MinDynamicBandwidth=20000
  2. Turned on substepping and lowered Substep Delta time and increased Maxsubsteps. This helped fix the slow fall of objects and weapons (including falling through the floor)
  3. Changed the FPS binding to different values. With or without - the problem is not solved.
  4. I created a new anim blueprint, and connected only one loop animation - it lagged.

Also, when I press the run button(shift), there is a slight jerk in synchronization, but I think these things are not related to this topic.

I would be grateful for any advice and suggestions.
On the video demonstration of lags. Below is the server where the animations are lagging, and above is the client with normal performance:

1 Like

Bump. Same issue here

I checked if there is such problem in other projects. It turned out that these lags are in any 5.2 project. I checked even on other PCs and the problem is exactly the same. On 5.0 animations are not slowed down, but still jittery.

What I did: I found information that I need to do two things. 1. bOnlyAllowAutonomousTickPose=false in Character class (PossessedBy)
2. Override and comment TickCharacterPose() in CharacterMovementComponent (MoveAutonomous)

But I ran into a c++ related problem in second task. I don’t understand how this function can be overridden, because when I just wanted to copy the function code from the CharacterMovementComponent to my child component, the namespace member is not defined for me: CharacterMovementCVars::EnableQueuedAnimEventsOnServer. (before that, I managed to overwrite it and in general there are no problems, I replaced my component from the standard one)

This happens because CharacterMovementComponent.h has only two external members.
image

Whereas the required namespace member is in CharacterMovementComponent.cpp .

And if i directly include “Engine/Private/Components/CharacterMovementComponent.cpp” in my component.cpp i get an errors:
a) ‘PerfCountersModule.h’: No such file or directory(fixed)
b)Cannot open include file: ‘CharacterMovementComponent.gen.cpp’: No such file or directory

So what can I do to fix this? And as I understand Super will not help here, because I need to disable (comment) the TickCharacterPose call (not just change the variable).

1 Like

Instead of commenting TickCharacterPose in MoveAutonomous, you can override function TickCharacterPose and nullify it in the desired case - should be something like

CharacterOwner->GetRemoteRole() == ROLE_AutonomousProxy && IsNetMode(NM_ListenServer) && !CharacterOwner->IsPlayingRootMotion()

Could probably also be done similarly in a SkeletalMeshComponent subclass by overriding ShouldTickPose().

1 Like

Thank you for your answer.

image

I solved this problem like this. It seems that these variables do not change in the code, so I can create copies of them in my component.h file and equate them to 1, just like in the original class. Or will it cause problems?

Now the animation looks good on the listen server.

But when testing, I found that if the server hosts a weak computer, then clients see its animations very lag and frames are skipped.(there is no way to check whether there would be lags on other clients to, since I test through only 2 computers)

Also, on such a weak computer, a very strange problem was discovered - thrown weapons fly away, as if they have broken physics or problems with collision (but i saw it erlier before changing character and component files).

Perhaps it should be limited somehow? If the session is hosted by a powerful computer, there is no problem at all! And it would be very inappropriate to leave it like that, since this problem affects users with good computers

2 Likes

Update: I decided to go into the code again and Intellisense this time showed me an error in the component about an undefined GetOwner () and as a result the component did not compile at all (earlier the error did not appear and the project was successfully packed). And apparently due to the fact that I switched the variable, and TickCharacterPose remained - there was an animation overlay, albeit a very strange one. After I include Character.h and recompiled - everything seems to work as it should (I really hope so).

I solved the second problem by simply increasing the delay between dropping the weapon and turning on its physics. Apparently due to the fact that the delay was equal to 0.1, weak computers did not have time to process this task. Actually, this is not related to the topic, but perhaps it will be useful to someone.

It is very difficult to find detailed information on network problems. For example, every developer who makes games through the listen server will be affected by this fix. I really wanted the flexibility to configure this initially, as I read in one of the topics (written by the way many years ago), it would be a great idea to make a boolean switch for these modes somewhere right in the engine.

That is why I tried to describe everything here in detail, in order to at least slightly expand the view of all these problems for future seekers of answers.

By the way, if you work with the Advanced steam session plugin, I had a problem with finding matches that occurred if I packed the game into an archive and the unzipped copy did not connect to the one that was archived before. So be careful with this. But nowhere did I see even close advice about this. (very weird btw)

1 Like

Thanks for this. Do you know of a reason why this is needed? In the source code of Character.cpp in PossessedBy() they explicitly state that

// If we are controlled remotely, set animation timing to be driven by client’s network updates. So timing and events remain in sync.

and that’s why they do:

Mesh->bOnlyAllowAutonomousTickPose = true;

But it would seem that this quite literally does the opposite of what they are intending. If it is a listen server, and that bool is true, then the animations of the client get out of sync rather than being kept in sync like they intend. Also the issue only occurs for me when client fps is high and server fps is low.

Anyways, thank you so much for this fix!

Epic please verify if this should be counted as a bug. @system

1 Like

Sounds similar to my issue not sure: When moving server side character of remote player, on listen server the animation from blendspace plays slower than on remote machine.
That’s the only case where it’s happening, server’s movement is fine on remote machine and remote machine movement is fine on remote machine.
Checked thousand times and both machines got same variable of speed that I plug into blendspace.

Is there any solution in blueprints?