Dear Community!
I have a problem that set back my game development with months. I am not a programming expert nor a Unity one. I have watched many tutorials, built some basic projects to get the idea.
I am working on a 2D sidescrolling mobile game, but my problem is that it lags really hard. Although the stats window shows 60+ FPS it is lagging.
The best I could achieve is everything running smoothly and only a few skips or “camera jumpbacks” happened in a pattern.
The problem is that I DID NOT have this problem before but one day I suddenly started experiencing it.
I have done a complete formatting of my C:/ drive, reinstalling Unity, I have the latest patch. I also made a full clean on my computer deleting useless files and then defrag-ed my drives.
I tried pulling out the LAN cable, checking if it was the problem.
I tried debugginb my code and compressing textures. Didn’t work.
I opened a fully empty new project, put in a square, a few platforms for him to move on, and a background. AND IT LAGS!
My GameObject has a Rigidbody2D, and a really simple script to make it move:
public float moveSpeed;
private Rigidbody2D myRigidbody;
void Start () {
myRigidbody = GetComponent<Rigidbody2D>();
}
void FixedUpdate () {
myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);
}
It works and moves the object. The Camera has the most basic follow script:
public GameObject Player;
void Start () {
}
// Update is called once per frame
void Update () {
transform.position = Player.transform.position + (new Vector3 (1, 1.0f, -1));
}
That’s it, that is all my new project has.
Here’s a video about the lag. The capturing enhanced it a bit but still gives the felling of it.
With VSYNC I have 60+ FPS and lag. Without VSYNC I have 3000 FPS and lag.
I tried moving the main character in many different ways. Using rigidbody’s velocity, using transform.position, using time.DeltaTime, I have rebuilt it according to many “2D runner tutorial”.
Either way the problem stayed. I would understand that in my own project something is done bad/unprofessionally/unefficiently since I am not that experienced. But in a brand new empty projects I can’t accept it. I have also tried many different ways on the Camera to follow the character. Used unity’s built in scripts, used scripts from tutorial, used scripts I downloaded. Problem stays. I have read MANY forum topics about this and tried the solutions given in comments.
I also provide my PC configuration:
Motherboard: Asus B85M-G
Processor: Intel(R) Core™ i5-4570 CPU @ 3.20GHz, 3201 Mhz, quadcore,
BIOS-version/-date: American Megatrends Inc. 0604, 2013.09.13.
SMBIOS version: 2.7
Graphics Card: NVIDIA GeForce GTX 650 2 GB
Built-in grapchics card(I use this for my second monitor): Intel(R) HD Graphics 4600 (2 GB memory)
I have a 1 TB hard drive and a 1 TB external hard drive.
Unity is on my internal hard drive and files for it are on external. Should this be a problem? I don§t think so but can be.
Please, I can’t continue my game until every blank project lags this hard, and I’ve browsed many questions on UntyAnswers.
Thank you for your help in advance,
Navetelen