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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question Simple ECS Project Optimization Help

Discussion in 'Physics for ECS' started by Akansh, Dec 24, 2020.

  1. Akansh

    Akansh

    Joined:
    Feb 24, 2013
    Posts:
    27
    I have a simple DOTS project using Entities, Hybrid Renderer, and Physics that I've been working on as DOTS progresses. However, I'm wondering if there's anything I'm doing wrong or what I can do to optimize this project overall. I'm not sure what areas I could change in my code to increase performance.

    https://github.com/AkanshDivker/Simple-ECS

    I noticed a few things so far. Before I switched my project to use the new Physics package, I could stack up thousands of entities without any issues. I used to be able to run 50,000 seamlessly but now it seems to have been halved without encountering a serious performance drop.

    In addition, I noticed that my ball graphics (MovementSystem) stutter when moving, now that it's Physics based. I'm not sure how to go about fixing the stutter that occurs when trying to move the player.

    Greatly appreciate any help and feedback, thanks :)
     
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Hi @Akansh , I took a brief look at your project and it looks nice. As a potential improvement, I'd advise running CollisionSystem and MovementSystem jobs on worker threads instead of main, by replacing Dependency.Complete() with CommandBufferSystem.AddJobHandleForProducer(Dependency) and calling Schedule() instead of Run() .

    These doc pages may help:
    https://docs.unity3d.com/Packages/com.unity.entities@0.7/manual/ecs_job_dependencies.html
    https://docs.unity3d.com/Packages/c...ase.html#Unity_Entities_SystemBase_Dependency
    https://docs.unity3d.com/Packages/com.unity.entities@0.4/manual/entity_command_buffer.html
     
    Akansh likes this.
  3. Akansh

    Akansh

    Joined:
    Feb 24, 2013
    Posts:
    27
    Thanks for your help! I applied the changes you recommended. Hopefully, I did it all correctly.

    I still can't figure out the issue with the player's graphics (sphere) stuttering when moving, it looks pretty jittery when applying motion.