Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Horrible Input Lag in clean project

Discussion in 'Editor & General Support' started by Taien, Dec 8, 2020.

  1. Taien

    Taien

    Joined:
    Dec 8, 2020
    Posts:
    2
    I started a clean project to work on a game idea some friends and I had. I just reinstalled Windows last month so this is a fresh install of Unity and Visual Studio 2019.

    I'm having so many problems I can barely describe them here. I want to make a video and post that but I'll see how this works first:

    When I first installed Unity and created this project, the first thing I noticed was how slow and choppy the entire editor was. Entering text in the name of a file or in any object's properties made it clear I was getting about 5fps. Eventually after days of searching the internet I found a command line option (-force-opengl) which seemed to make that better.

    But now I've started setting up some controls for my main (character) object, and they are extremely rudimentary:


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Space_ShipController : MonoBehaviour
    6. {
    7.     public float turnAccelerationRate;
    8.     public float accelerationRate;
    9.     private float turnSpeed;
    10.     private Rigidbody2D myBody;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.         turnSpeed = 0;
    16.         myBody = GetComponent<Rigidbody2D>();
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update()
    21.     {
    22.         //ship rotation
    23.         if (Input.GetAxis("Horizontal") < 0)
    24.         {
    25.             turnSpeed += turnAccelerationRate;
    26.         }
    27.         else if (Input.GetAxis("Horizontal") > 0)
    28.         {
    29.             turnSpeed -= turnAccelerationRate;
    30.         }
    31.         else if (Input.GetKey(KeyCode.Space))
    32.         {
    33.             if (turnSpeed > 0)
    34.                 turnSpeed -= turnAccelerationRate;
    35.             else if (turnSpeed < 0)
    36.                 turnSpeed += turnAccelerationRate;
    37.         }
    38.  
    39.         myBody.rotation += turnSpeed;
    40.  
    41.        
    42.         if (Input.GetAxis("Vertical") < 0)
    43.         {
    44.             myBody.AddForce(transform.forward * accelerationRate, ForceMode2D.Force);
    45.         }
    46.         else
    47.         {
    48.             myBody.AddForce(transform.forward * -accelerationRate, ForceMode2D.Force);
    49.         }
    50.     }
    51. }
    52.  
    When I run the program, pressing any key on the keyboard causes a noticeable frame drop of over 100ms, somewhere slightly below 200ms. Obviously this makes any input cause the game to drop frames.

    I've also been having problems in Visual Studio 2019. Every time I open a file from the project I am told that I'm targeting the wrong framework, despite having the correct framework installed and selected. I even tried installing this framework (4.7.1) using NuGet for every subproject in the solution. It worked for that session, but then stopped working again.

    Sometimes Unity starts to repeatedly fail to load the editor window, and I'm asked to revert to factory settings, which I do, and then I get the same error again in a repeating loop. Then I have to delete files from the appdata folder to get Unity to work again.

    Sometimes when I open the script files in VS2019 through Unity, VS2019 starts erroring about about some component not being found (I forget the exact error), and there's no way to stop it from spamming errors except to force-close it.

    What exactly is going on here?

    I'm using Windows 10 and have a beefy gaming PC.
     
  2. Taien

    Taien

    Joined:
    Dec 8, 2020
    Posts:
    2
    I tried completely uninstalling Unity, and then reinstalling it through Visual Studio Installer, and then running a Visual Studio repair operation. Same problems. Is there a certain amount of free space Unity needs on the system drive? Because my C drive is down to about 7 gigs free.