Search Unity

Physics2D.Simulation Performance Issues (5-7FPS) Issue not present with 3D colliders and physics.

Discussion in 'Physics' started by douglasg14b, Apr 4, 2015.

  1. douglasg14b

    douglasg14b

    Joined:
    Oct 2, 2014
    Posts:
    34
    EDIT: If I try this with 3D physics and colliders I get ~5-10x the performance.

    I made a fairly simple test scenario where I had a bunch of ships all shooting at a central target. Each turret has it's own circle collider that's used to check it's range from a specific target (and to identify if a target has entered it's range). They also have a 2D line cast to make sure their target is within line of sight, and is also within a certain range.

    The projectile is a small sprite with a small circle collider attached and a rigidbody.

    I have 80 turrets shooting one projectile every 10 seconds (staggered) and 4 turrets shooting 10 projectiles per second. I noticed the performance tank the more turrets I added, even if none of them where actually firing.
    _____________________________________________________________________________________

    I also tried instantiating 120 projectiles per second from a single unit to see if it was the rigidbody movement, after over a thousand projectiles I was still at 100FPS+. It does not seem to be that. It also does not seem to be the OnTriggerEnter or OnTriggerExit behavior either, since that is under Physics2D.ContactReporting.

    I also created a part of the scene with 80 empty gameobjects and added a circle collider to each with IsTrigger selected. When the projectiles fly through the colliders the game goes from 700FPS to ~1-2FPS in waves. It will be fine for a few seocnds, then the Physics2d.Simulate spikes to a few hundred ms for a second or two, then it goes down for the next 3-4 second, then back up, then back down. I can't make much sense of it.

    _______________________________________________________________________________________

    What is causing this massive slowdown with only a few units, and maybe 200 projectiles? How do I go about increasing the performance?




    3D Profiler:

    Pic of Scene:

    Colliders:

    Shooting:
     
    Last edited: Apr 4, 2015
  2. VictorFR

    VictorFR

    Joined:
    May 4, 2014
    Posts:
    15
    physics.simulate is when you use trigger movement by scripts seems.