0 votes

Hello,

First off, apologies if this has already been answered before, I looked for a similar topic in 3d but nothing turned up from my searches.

I am building a 3d game, in which I would like a large amount of enemies to chase the player : ~50 enemies at the same time would already be a nice target. To guarantee quick pathfinding, I am using a custom made FlowField-based approach.

The pathfinding or collision detection with the terrain works really well with one enemy or large amount of isolated ones. However, when they collide with each other, or when the player collides with them, the game slows down to 10 fps with even as little as 5 enemies (and gets worse with more enemies).

The enemies themselves are for now represented each by a KinematicBody, with as children one Cylinder CollisionShape and a Capsule MeshInstance. Each body is moved using move_and_slide_with_snap.

The problem is only encountered in situations where they collide against each other continuously for a few frames (for example when they reached their goal, when they are crammed in a small space etc.).

Am I doing something obvious wrong here ?

I tried to be as straight to the point as possible because this doesn't seem to be related to my project in particular, but if this is an uncommon issue I'll happily recreate a thread with more specific details.

Godot version 3.2.4
in Engine by (315 points)

I'm not sure if this is normal to have such a drop in performance with only 5 enemies. Anyway, if you don't find another solution, you could add rules to your enemy to keep them apart, avoiding the collision. They could have an area where they check the distance with close enemies, and try to stay away.

I don't think either. However while profiling I couldn't come to the conclusion that my own GDNative code was the issue, so it seems to be up with Godot. I think a good course of action would be to test the code on another machine honestly.

Yes, I was already thinking about adding some flocking behaviors ! This averts the issue, since when not colliding with each other the enemies behave fine. I'll probably add some logic on top, like the enemies following their path without physics when far the player's field of view, to save on CPU time with lots of opponents.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.