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
- This topic has 5 replies, 3 voices, and was last updated 4 weeks ago by
Terence.
-
AuthorPosts
-
July 19, 2024 at 3:17 am #15324
Norman Harig
Participant::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?
July 19, 2024 at 4:21 pm #15327Terence
Keymaster::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.
July 19, 2024 at 5:58 pm #15329Norman Harig
Participant::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?
July 19, 2024 at 10:58 pm #15330Terence
Keymaster::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.
August 9, 2024 at 11:20 pm #15551Anthony
Silver Supporter (Patron)::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
August 10, 2024 at 5:49 pm #15555Terence
Keymaster::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.
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: