EDIT: Video of symptom can be seen here → Sudden loss of movement speed when using acceleration curve - Unreal Engine 4.21 - YouTube
For the last few months I’ve been battling this annoying issue whereby a game character in multiplayer will be running along and suddenly loose speed due to some weird network correction. I’ve whittled down the issue to what seems to be getting close to maximum speed while using a variable acceleration value.
I have attempted to work on the issue in blue prints, using UpdateMovement callbacks, custom C++ character and movement controllers and still I keep hitting this ■■■■ problem. Its really feeling like some bizarre bug. Especially when I can jam up the character’s max walk speed and the issue is deferred along.
1: Create a new project based off the Third Person template. Remove the walls around the level and expand the base floor to 50x scale in the X+Y so you have plenty of room to run around
2: Open up the “ThirdPersonCharacter” blueprint
3: Add a Float, name it “CurrentSpeed”
4: Add a CurveFloat, name it “AccelCurve”
5: Set two points in the AccelCurve to the following values
- Time = 100, Value = 1000
- Time = 1000, Value = 10
6: Create a Widget and name it “HUD”
7: In that widget, create a Text, and bind its text value to the “CurrentSpeed” of the character
8: While also in the widget, make a progress bar and bind its value to current speed. But ‘MAP Range’ the value range so 1000 = 1. Thus ProgressBar is full when speed is 1000
9: Back in the ThirdPersonCharacter blueprint
10: Set the value of MaxWalkSpeed of the CharacterMovement component to “1000”
11: Add to the blueprint event graph the following nodes
=============================
Testing:-
Start the game, in normal single player mode in the editor. Run around gathering up speed. You want to get to the speed of 1000.
You will notice as your spread increases the acceleration slows down.
Stop the game
Now start it up again but in Dedicated Server mode
Open the console and type in the following command
- p.NetShowCorrections 1
Run around as you did earlier.
NOTICE: That as you reach the near the maximum speed of 1000, you will get movement corrections and you suddenly loose a MASSIVE amount of speed. Possibly dropping down to 600 to 800 speed.
Feel free to add additional debugging to compare your server speed and client speed. What you will see is that on the server it will suddenly show you slowing down for no real reason and because of this it’ll make a significant correction.
Try changing the MaxWalkSpeed to 1100, and notice the issue happens far less when hitting 1000. Set the value and see that the issue happens as you approach maximum speed.
This issue happens on 4.15, 4.19, and 4.20. Will try 4.21 soon after downloading it.
==========
Suggestions anyone?
==========
- The end goal of this is to have a character that has the ability to sprint.
- When they sprint, as they approach their maximum speed, their acceleration is reduced
- Also there will be a stamina value which influences the acceleration AND maximum speed value.
- Eg, if they are at half stamina, they can not accelerate as fast, nor can they reach a maximum speed like a well rested characher.
- If they are out of stamina they can only sort of jog along and not run as fast as a well rested character. They would have to essentially walk/stop moving, to regain their stamina.
Older post here trying to look into the symptoms Adjusting the MaxWalkSpeed many times on a multiplayer game, stuttering - Multiplayer & Networking - Unreal Engine Forums