Godot does not have a technology similar to Unity's DOTS.

Godot Version

4.2

Question

I want to create a game where the player entities need to have thousands of nodes on the same screen without lagging, ideally tens of thousands. The nodes should bounce off the walls when they hit them. However, when I generate hundreds of nodes, it already causes lag. I’m using the CharacterBody2D node.

The statement velocity = player_direction * speed * delta takes up the most frame time because hundreds of nodes are running this statement simultaneously, causing lag.

If Godot doesn’t have a technology similar to Unity’s DOTS, is there any way to solve my problem? I hope an expert can help me with this. Thank you.

Why are you using CharacterBody2D out of interest? I would only use that if I needed to as its very heavy on physics simulation.

1 Like

There’s a feature proposal for this kind of functionality, but it hasn’t been implemented yet.

1 Like

You can use the servers directly. More information here Optimization using Servers — Godot Engine (stable) documentation in English

2 Likes

Because the player collides with the wall, it needs to bounce back.

I am currently working on a single-player game, but thank you for your response nonetheless.

Thank you for sharing.

@ysypnbh
A few points of clarity:

  1. CharacterBody2D is a very performance intensive physics node that is intended for cases where you want complex physics behaviour. As the name implies it is intended to be used with your main player character, rather than for thousands of other entities. You should consider not using CharacterBody2D.
  2. Godot uses a “server” architecture for Physics and Rendering. The link that mrcdk linked to is not about networking with servers, it is about optimizing games like yours by using the Physics server directly instead of using nodes. By using the Physics server directly you can improve performance significantly.
2 Likes

Thank you. It was my misunderstanding. Thank you for your advice. I may need to study further on how to use it.