Forum begins after the advertisement:


[General] Performance Optimization

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [General] Performance Optimization

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #15324
    Norman Harig
    Participant
    Helpful?
    Up
    0
    ::

    How would you guys optimize performance?

    In game there will be hundreds of gameobjects with colliders. According to the profiler tool, around 70% of the performance is drained by collisions of enemies with each other. I know I can reduce the fixed time stamp but thats not enough.

    What ohter steps could I take regarding the many collisions?

    #15327
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    To optimise the collision overhead, you can disable collision detection between enemies using the Layer Collision Matrix in the Unity physics engine.

    The simplest way is to assign all the enemies to the same layer, and disable collision among GameObjects that belong to the same layer. Or you can make it so that only certain types of enemies collide with each other, and others don’t.

    If you remove collisions on 50% of the enemy, that will be 35% of your performance overhead removed.

    #15329
    Norman Harig
    Participant
    Helpful?
    Up
    0
    ::

    I thought about that. I am not an expert here. But when I disable the collision between objects with the “enemy” layer, the enemies just overlap each other. Am I overlooking somthing?

    #15330
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    I thought about that. I am not an expert here. But when I disable the collision between objects with the “enemy” layer, the enemies just overlap each other. Am I overlooking somthing?

    Yes, if you disable the collision between objects, the enemies will overlap each other. So you have to be selective about which enemies you disable, or spawn enemies in a way that it won’t matter if they don’t have collision with each other. For e.g. you may consider removing overlap for flying enemies, since they can “fly over” land enemies.

    Or if you are up to Part 21 of our tutorial, you can configure the mobs so that they spawn spread over a larger area.

    #15551
    Anthony
    Participant
    Helpful?
    Up
    0
    ::

    Hello!

    I don’t know if you still have the issue but I found that video and I think it may be interesting for you:

    In the video, he tries to reply to you question avoiding using rigid body but replicating it “manually”.

    Anthony

    #15555
    Terence
    Keymaster
    Helpful?
    Up
    0
    ::

    He is right that not using Rigidbodies will speed things up. But he is tackling the problem as though we are making a simulation, not a game, because he wants to continue to simulate elements outside of the camera, which I don’t agree with. This will add a lot of unnecessary overhead to the game, without adding much gameplay value. You can make the game feel crowded without keeping 1000s of enemies running simultaneously, and it’s unnecessary to keep so many enemies running because you can only fit a few 100 of them on screen at anytime anyway.

    Unity’s physics system (aka the rigidbodies) also do make use of some of the techniques he describes, such as spatial partitioning, so it is unnecessary to build our own system and our own version of that. Unity’s version is definitely slower, because they are building it generally to support all games, but we are not running into any performance issues at the moment, as long as we keep the enemy counts in the 100s.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: