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

Unity game starts lagging and then freezes

Discussion in 'Scripting' started by SHBYT, Mar 28, 2020.

  1. SHBYT

    SHBYT

    Joined:
    Nov 2, 2018
    Posts:
    14
    So I've made a machine learning simulation using the NEAT algorithm and I can't figure out why after about 5 generations the game starts lagging and then freezes with high CPU usage.

    Could it be something accumulating? I've cleared any lists after I've used them as well as deleting any unnecessary gameobjects that I don't need but it's always after 4 or 5 generations it starts lagging.

    I have no idea what is causing it or any idea how to identify and fix the issue.

    Does anyone know anyway I could go about solving this?

    Here's a video showing the issue:



    I understand there's not too much to go on but I don't really know why it's lagging this badly.

    If needed I can provide a link to download the project.
     
  2. Raffalius

    Raffalius

    Joined:
    Sep 11, 2019
    Posts:
    4
    Im new at this, but maybe try to destroy clones after a certain amount of time?
    Hopefully that fixes your issue :)

    Example: Destroy(GameObject.Find("the name of the gameobject(Clone)"), 5);
     
    Last edited: Mar 28, 2020