Hi all!!
There's a weird stutter when my character moves (which on higher FPS/refresh rates makes it look super blurry) and I'm curious just to why it is/how to prevent it from happening. I've got a simple movement script set up:
// PlayerMovement.cs
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
private Rigidbody2D rb;
private Vector2 moveInput;
public float playerX = 0f;
public float playerY = 0f;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
rb.linearVelocity = moveInput * moveSpeed;
playerX = rb.position.x;
playerY = rb.position.y;
}
public void Move(InputAction.CallbackContext context)
{
moveInput = context.ReadValue<Vector2>();
}
}
And a "smooth" camera follow
// PlayerFollow.cs
using UnityEngine;
public class PlayerFollow : MonoBehaviour
{
public PlayerMovement playerMove;
public float smoothSpeed = 10f;
void LateUpdate()
{
if (playerMove == null)
{
return;
}
Vector3 targetPosition = new Vector3(playerMove.playerX, playerMove.playerY, -10f);
transform.position = Vector3.Lerp(transform.position, targetPosition, smoothSpeed * Time.deltaTime);
}
}
Could it be the camera LateUpdate that's causing the issue?