+2 votes


I'm using the Mono version of Godot 3.2 on Windows 10.
I have an object that consist of the following nodes

Area2D (root)

I have 300 instances of this object in my game and I would like each instance to rotate, move around and I also would like to check collision with this object by sending and listening to a signal if anything enters the collision area which is a 2D polygon collision area.

The problem is that, even if this object do nothing but rotate, my game runs only at 5 FPS with 300 instances present in the scene. It doesn't move and I don't check collision but rotate it.
This is the code I'm using to rotate the instances:

this.Rotation -= rotationSpeed * delta;

The C# script is attached to the root (Area2D) node.

Only a single line of code doing nothing but rotate the object and I get only 5 FPS with 300 instances in the game. In similar scenario in other engines I get stable 60 FPS with even 1000 instances in the game and even if the instances are moving and do collision check.

I was searching the forum for optimisation and did read the docs but I can't figure out what am I doing wrong and I have no idea how I could improve the performance in Godot. It is a very simple project also and it is surprise me it runs so badly with 300 instances.

I would appreciate any advice or links to articles regarding what to do different and what to look for when you dealing with lots of dynamic objects in Godot.


in Engine by (66 points)

you don't need "this." at the beginning

2 Answers

0 votes

In my case the problem was that I was rotating the Area2D node directly. It seems it is not a good idea for some reason.
If I change the hierarchy to:

Sprite (root)

and I attach the script to the sprite node and I rotate and move the sprite node instead the Area2D and send the collision signal from the Area2D to the Sprite, I get stable 60 FPS instead of 5 with 300 instances in the game.

However, if I have 1000 instances I get only 12 FPS. In other engines in similar scenario I get stable 60 FPS even with 1000 instances.
Wondering if is there anything else I can try.
Anyhow, if anyone has a similar performance problem, make sure you don't rotate and move the Area2D node directly.

by (66 points)
+2 votes

When you have a lot of instances, it's better to bypass the node system by using servers directly: https://docs.godotengine.org/en/latest/tutorials/optimization/using_servers.html

by (11,891 points)
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.