The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+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 (76 points)

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

3 Answers

+1 vote

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 (76 points)
+2 votes

When you have a lot of instances, it's better to bypass the node system by using servers directly:

by (12,878 points)
0 votes

I have noticed this behavior on 3.4.4-mono. How I fixed it appears to be similar to you -- there might be some bug with attaching a script onto an Area2D itself I found that when I have an external script that modifies area2d, I get 60 fps. A script on an Area2D causes 5 FPS or so.

by (30 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 Frequently asked questions and 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 [email protected] with your username.