No smooth motion, Camera stutters
I can't get smooth motion when moving with my player/camera (don't know which one of them causes the problem).
The 2 ways I tried are:
1. Put the movement methods in FixedUpdate() and set the Update Method of the camera to FixedUpdate().
2. Put the movement methods in LateUpdate() and set the Update Method of the camera to LateUpdate().
Way 1: Constant bad motion when moving or looking around, but player is in sync with the camera. Feels like playing with very low fps.
Way 2: On unlimited fps(~ 800 fps) the motion seems fluent(except rarely stutters) and with limited fps of 60(Application.targetFrameRate = 60) the motion is acceptable but the stutters can be noticed. Also a problem with Way 2 is that motion should not be stored in LateUpdate() or Update(), since FixedUpdate() is designed for movement and physics.
I simplified my 3rd Person player, with a CharacterController component attached to it and added a FreeLookCamera(Cinemachine) in the scene which Follows & LooksAt the player.
Code and screenshots made with Way 1
The movement script (attached to the player):
public float walkSpeed = 4f;
private CharacterController controller;
private Vector3 direction;
private void Awake() {
controller = GetComponent<CharacterController>();
}
private void Update() {
direction = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
}
private void FixedUpdate() {
if(direction.magnitude >= 0.1f) {
controller.Move(direction.normalized * walkSpeed * Time.deltaTime);
}
}
In case someone asks, I already build it in both versions but the problem remains..
So my question: What can I do to achieve a fluent camera/player movement?
Thanks!
Answer by Slater7 · Aug 17, 2020 at 04:25 PM
Was able to get it done myself.
For anyone having stutters/jitters when moving/looking in the simplest scenes:
- Disable vsync
- Deactivate any code which limits the framerate
- Restart unity
Your answer
Follow this Question
Related Questions
Using Camera.main.ViewportToWorldPoint to limit player movement in the Y direction 0 Answers
How to make an object go the direction it is facing? 0 Answers
How to make FPS character jump in the direction my camera is facing? 0 Answers
3rd person controller with static cameras 0 Answers
Player Movement with Camera Script 1 Answer