I’m trying to set my Character’s Yaw based on the change provides by a bound axis input. I have a BindAxis call in my PlayerController class, which calls a method in the same PlayerController class - that method then calls a RotateCharacter method on my Character class and passes in the float value.
In my RotateCharacter class, I have the following code …
When I run the game, this works and causes my character to rotate around the yaw, but the movement is very sluggish and not smooth at all. Also, it does not seem to cause my character to appear rotated on other player’s games.
Any idea why the sluggish movement is happening? I’m sure I’m doing this wrong - I’m just starting to learn.
About the fact that it doesn’t happen on other clients, that’s quite normal as you’d have to either do a remote procedure call (RPC) or tick a bunch of booleans somewhere in your actor to replicate your newly set rotation (I haven’t tried it myself but I’d assume that the Character class boolean “ReplicateMovement” should also replicate SetRotation… Probably). Either way, your game cannot guess what change should be replicated and what change shouldn’t, so you have to do something on your end before that happens.
About the sluggish movement, it’s something that I have seem myself too. If you find a solution to your issue, I’d be very interested. My needs were more in regard to a cosmetic perpetual, constant-speed rotation, but the way to do it and the end result are basically the same then your case. So far, the only thing of use that I have found is that the sluggish movement is less visible at slower rotation speeds.
Well, I notice that if I tell my character to not ignore controller pitch and yaw, then I can use the AddControllerYawInput and AddControllerPitchInput methods to rotate my character, and these rotations appear smooth - they also replicate when testing in multiplayer. So, those two methods are doing something the “correct” way.
I just don’t think I want my character to rotate entirely based on the controller rotation. I think I’d rather be a bit more manual with it.
This is my first post, so I apologize if I miss some kind of rule/social-norm
The problem as I see it is that you aren’t using any form if Linear Interpolation (Lerp).
Setting the rotation will do exactly that, suddenly snap the view to the rotation, this isn’t going to be too great a problem if it is client-side as the “snapping” happens frequently, but latency and alike means synchronization will cause “jitteryness”, to create a smoother movement you want to have a “end rotation” direction, and Lerp the result over time every-tick, until the object is pointing in the direction you want.
Really, what’s wrong with the template code? Next step is to look at the ShooterGame to see how to do sprinting and targeting speed changes. If that doesn’t help, next step is to read the code for the CharacterMovementComponent (10000 lines) to understand how to implement your own prediction and movement smoothing.