Hey guys!
Took another look at movement in my game and found out that it only works smoothly when using a constant speed - super happy that I found it out though and got to experience the smoothness now. : )
Could use some help on how to get the client predicted movement working properly with constantly changing speed caused by different character movement states like idle, walking and running mainly at this point.
Currently, when using a variable speed, the character makes a bit choppy transition from idle to running especially. It feels like the player gets quickly corrected by the server before being able to properly make the quick change from idle to running, so basically from zero to full speed.
My setup:
- 3D top-down view
- Server authorized and client predicted movement
- Character faces mouse cursor and uses it as the targeting pointer for skills and attacks
- Related input commands include cursor position (XZ) and two booleans for moving/not and running/walking
- Related resulting commands include Position (XZ, with smooth corrections on, tp threshold 3 and no compression) and Speed (smooth corrections on, compression 0-25 with 0.1 accuracy) (not sure if 0.1 accuracy means it is rounded to 1 digits or not btw, so have to look into that at some point)
- Tried different correction interpolation frames between 1 and 30 and did not notice much difference there for some reason (might need to give it another look later on, though, the main problem is probably elsewhere in this case)
- Reset state is applied like this:
I have noticed most of the cases seem to be using velocity as a resulting command that includes both direction and speed. I currently let players control the direction completely as the character rotation is instantaneous and it also affects the targeting so I think I would only need to send speed as the result in addition to position.
Character movement on both controller and owner:
context.MyCharController.Move(context.transform.forward * context.StatManager.TotalSpeed * BoltNetwork.frameDeltaTime);
TotalSpeed is updated on both controller and owner separately whenever the simulation is run and the movement state (idle, walking, running etc) changes. Once I move on to testing speed mods caused by status effects I might add a speed modifier as a state property but have to see about that later on.
So it would be really cool to get some ideas on what would be the best way to correctly sync the speed variable in a game with this kind of mouse oriented targeting and movement system and different character states that affect the speed. It seems to work smoothly when just using a constant speed. I am also interested in hearing about any potential other improvements.
One thing that came to my mind while writing, and I remember thinking about it when working on the movement system, is that I do not have a resulting command for the movement state itself. I might need that as well but I think I am probably doing something else wrong as well. Gotta go do some logging as well still ->
Any thoughts are much appreciated! Thanks!
Took another look at movement in my game and found out that it only works smoothly when using a constant speed - super happy that I found it out though and got to experience the smoothness now. : )
Could use some help on how to get the client predicted movement working properly with constantly changing speed caused by different character movement states like idle, walking and running mainly at this point.
Currently, when using a variable speed, the character makes a bit choppy transition from idle to running especially. It feels like the player gets quickly corrected by the server before being able to properly make the quick change from idle to running, so basically from zero to full speed.
My setup:
- 3D top-down view
- Server authorized and client predicted movement
- Character faces mouse cursor and uses it as the targeting pointer for skills and attacks
- Related input commands include cursor position (XZ) and two booleans for moving/not and running/walking
- Related resulting commands include Position (XZ, with smooth corrections on, tp threshold 3 and no compression) and Speed (smooth corrections on, compression 0-25 with 0.1 accuracy) (not sure if 0.1 accuracy means it is rounded to 1 digits or not btw, so have to look into that at some point)
- Tried different correction interpolation frames between 1 and 30 and did not notice much difference there for some reason (might need to give it another look later on, though, the main problem is probably elsewhere in this case)
- Reset state is applied like this:
- transform.position = Cmd.Result.Position;
- StatManager.TotalSpeed = Cmd.Result.Speed;
I have noticed most of the cases seem to be using velocity as a resulting command that includes both direction and speed. I currently let players control the direction completely as the character rotation is instantaneous and it also affects the targeting so I think I would only need to send speed as the result in addition to position.
Character movement on both controller and owner:
context.MyCharController.Move(context.transform.forward * context.StatManager.TotalSpeed * BoltNetwork.frameDeltaTime);
TotalSpeed is updated on both controller and owner separately whenever the simulation is run and the movement state (idle, walking, running etc) changes. Once I move on to testing speed mods caused by status effects I might add a speed modifier as a state property but have to see about that later on.
So it would be really cool to get some ideas on what would be the best way to correctly sync the speed variable in a game with this kind of mouse oriented targeting and movement system and different character states that affect the speed. It seems to work smoothly when just using a constant speed. I am also interested in hearing about any potential other improvements.
One thing that came to my mind while writing, and I remember thinking about it when working on the movement system, is that I do not have a resulting command for the movement state itself. I might need that as well but I think I am probably doing something else wrong as well. Gotta go do some logging as well still ->
Any thoughts are much appreciated! Thanks!