Performance with dynamic objects

Hey there.
I’ve been working on my project (Virtual Survival) and i’ve been encountering problems with the performance.
I’ve done tests to see what was causing the lag, and it seems that the enemies are the ones causing it. All of my enemies are set to dynamic physics mode, and when i have, say, 5 or 8 the performance is perfect. But once it starts spawning a lot more, the game suddenly starts to lag a LOT.
The enemies meshes all are of 32 polygons each, so it can’t be the polygon count.
Something i’ve noticed is that when i have about 50 or 80 enemies pursuing the player, it lags a lot when the enemies collide with each other, and not only when they collide, it still lags even if they’re far away from each other.
So can anyone suggest me the best physics setting for them, or if there’s nothing i can do?
I did a test on another blend where there are about 150 cubes all set to dynamic following a cube and it doesn’t lags.
Any help is appreciated! :slight_smile:

Does the Enemies have a cube as collision bounds ?

Yes. I’ve giving them collision meshes but it still doesn’t help.

Disable use framerate (unlimited frames mode) , and take a screenshot with them when starting to lag.

Here are 2 screenshots, on the first one you can see the huge amount of enemies near the player, and i was experiencing a lot of lag.
One the second one i was shooting at them (Sorry for the huge amount of particles, they’re part of the gameplay). Also i should add that there’s also a big number of animations going on: The trails, the particles, the explosions all have particles and they all are part of the gameplay.

What type of physics does the particles have ?
Does your enemies have “box” as collision box?
Physics really sucks,even with a few object bge still lags.
It is not hard to code “physics” , they would be static but with act like dynamic if you code them a bit :slight_smile:
Make sure almost everything has “no collision” in physics tab, never use static with ghost.

The particels are set to static and ghost.
And the enemies do have box as collision box.
And i’m not that good at coding, plus my enemies use the force motion to move (So that the player can have a chance of avoiding them).

Thats a bad move, set eveerything that does not collide to “no collision” , this way you save a lot of resources, static and ghost is a bad solution. :wink:

Seems like that helped a bit.
Got around 40 enemies at the same time and experiencied a 10 FPS downgrade. However when i get 50 or 60 it goes down from 40-30 FPS to 15.
Even tho, i doubt the player would be able to handle such a number of enemies at the same time and still be able to survive.

You don’t really need that many enemies ! Trust me! I havent seen games to have so many enemies , just make them faster and stronger and you won’t need hundreds of them :wink:

Actually that’s the main point of my game.
The enemies are already pretty fast, and the idea is to swarm the player, so actually when you there’s that many enemies it’s pretty hard for the player to get them off him (My brother tested my game. He said that’s one of the things he likes about the game. That when it kills him, he just wants to come for more :wink: ).
Even tho, i plan on adding some enemies that blow up and kill a lot of other enemies.

Your logic is awfully high. PM me the source and I can optimise the logic at some stage.
Also, physics shouldn’t be that high. Are objects forced into each other on creation?

If it suits your purpose, you could also set the enemy collision bounds to sphere rather than cube since I believe sphere collisions are the fastest.

particle EVER no collision! mandatory!