x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Sudden loss of movement speed when using acceleration curve in multiplayer as character approaches maximum speed.

EDIT: Video of symptom can be seen here --> https://youtu.be/TDJ0oo5n2Qk

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 damn 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

alt text

=============================

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 https://answers.unrealengine.com/questions/814703/index.html

Product Version: UE 4.20
Tags:
accelproblem.png (205.6 kB)
more ▼

asked Jan 05 '19 at 07:29 PM in Using UE4

avatar image

ChiggenWingz
81 1 6 4

avatar image ChiggenWingz Dec 24 '18 at 02:28 AM

Also happens in 4.21.1

EDIT: And I've just realised the below forum thread is from UDK, and NOT Unreal Engine 4 related :(

*This forum thread also seems to describe similar symptoms and may be related. https://forums.epicgames.com/udk/udk-development/udk-programming-and-unrealscript/295060-how-to-replicate-velocity-instead-of-acceleration*

avatar image ChiggenWingz Dec 28 '18 at 10:44 AM

Note: I have used the code from https://github.com/Pantong51/AdvancedMovementComponent

which seems to get a lot of its design from the tutorial https://wiki.unrealengine.com/Authoritative_Networked_Character_Movement

I've probably look at that tutorial at least once a month for half a year now, and I think I have a better understanding now of it all. :P

The problem I'm seeing still seems to happen because I think I have a variable acceleration rate. Now if it was happening extremely often I'd suspect it would have been a similar symptom to changing MaxWalkSpeed or something every tick. But everything seems perfectly fine up until the point where you get close to the maximum speed. Thats when the reset of positions happen and the sudden loss of speed.

I also tried today a maximum speed of 500, and the issue did NOT seem to happen. But DOES happen when a max speed of 600 is set.

Yet still I can set the maximum speed to 2000, and just have a very low acceleration up to maximum speed and I dont seem to get the resets?

avatar image ChiggenWingz Dec 31 '18 at 04:55 AM

Video of the symptom can be seen here

https://youtu.be/TDJ0oo5n2Qk

avatar image ChiggenWingz Jan 05 '19 at 06:10 AM

I've also tried the above by using a custom character and movement component in C++ See attached ZIP

NOTE: If you use the code below. Make sure to disconnect the blueprint example above. You do not want the blueprint to be setting the MaxAcceleration variable of the movement component, otherwise you'll be fighting with the C++ code.

NOTE: also there is some code in there for toggling between a walking and sprinting state. I have removed the bulk of it and it is not being used.

When you use the code, you manually set the SprintSpeedMaximum in the characters movement component

Heres the meat of it:-

 float URW_MovementComponent::GetMaxAcceleration() const
 {
     const FVector LateralVelocity = FVector(Velocity.X, Velocity.Y, 0.f);
     return SprintAccelerationSpeedCurve->GetFloatValue(LateralVelocity.Size());  //Return the acceleration curve value which matches the current speed the character is moving at
 }

link text

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question