I have a plane, a first person camera, and a player controller in a scene. There's a weird stutter in the game preview even though there are not a lot of assets in the project, average FPS, and don't see lag on other heavier projects. I tried changing the asset and replacing with a cube, still see the lag.
Any idea what could be causing this? Game is not GPU bound.
Environment
- Windows 10 NVIDIA GeForce RTX 3060
- Intel(R) UHD Graphics
- Unity 2021.3.14f1
- DX 11
Steps to reproduce:
- Add plane + lighting settings (turned off lightbox and changed environment color to black)
- Add capsule
- Add player controller script
- Add first person camera script
- Add tree fbx
- Add audio source to tree fbx
- See visual stutter
- Tried deleting tree fbx and added cube to see if I
still get the visual stutter - still there - Tried deleting first person camera script - visual stutter still there
I think its a hardware issue because i see the visual stutter just moving assets in the game preview without running it. but i dont see it running other projects.
Player Controller script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
// The speed at which the character moves
public float moveSpeed = 5.0f;
// Update is called once per frame
void Update()
{
UpdatePlayer();
}
void UpdatePlayer()
{
// Get the input axis for horizontal movement
float horizontalInput = Input.GetAxis("Horizontal");
// Get the input axis for vertical movement
float verticalInput = Input.GetAxis("Vertical");
// Calculate the movement vector
Vector3 movement = new Vector3(horizontalInput, 0, verticalInput) * moveSpeed * Time.deltaTime;
// Move the character
transform.position += movement;
}
}
First Person Camera script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FirstPersonCamera : MonoBehaviour
{
// Variables
public Transform player;
public float mouseSensitivity = 2f;
float cameraVerticalRotation = 0f;
bool lockedCursor = true;
void Start()
{
// Lock and Hide the Cursor
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// Collect Mouse Input
float inputX = Input.GetAxis("Mouse X")*mouseSensitivity;
float inputY = Input.GetAxis("Mouse Y")*mouseSensitivity;
// Rotate the Camera around its local X axis
cameraVerticalRotation -= inputY;
cameraVerticalRotation = Mathf.Clamp(cameraVerticalRotation, -90f, 90f);
transform.localEulerAngles = Vector3.right * cameraVerticalRotation;
// Rotate the Player Object and the Camera around its Y axis
player.Rotate(Vector3.up * inputX);
}
}



