I'm optimizing using servers for a rather simple application of having cells, represented by 3D spheres, simply being born and attracted to each other when they are in close proximity. Either using custom physics or by using Area gravity.
Because I want to have up to thousands of instances, I have read read about optimization here, which promises the following regarding optimization using servers:
"For large amount of instances (in the thousands), that need to be constantly processed (and certain amount of control needs to be retained), using servers directly is the recommended optimization."
Now, I've done that, and I get around 2 FPS already at ~100 instances. This seems to me equivalent to the case when I used scenes. Hence, no qualitative difference in user experience between using servers vs using scenes. And far from the promise of being able to handle thousands of instances.
I'm hoping that the reason is my incompetence. It would be greatly appreciated if you could spot my folly by copying and/or reviewing the code I've pasted here. There are only two scripts: 1)
Spatial.gd attached to a main scene with a single Spatial node, and 2)
Cell.gd as an unattached script that exist in the FileSystem. It should be trivial to create a new project, add a Spatial node as the main scene with the
Spatial.gd attached, and create a new custom script with the code from
Cell.gd. Then simply run the project, whereby you will see 125 cells spawned with low FPS. The cells consist of 1) a spherical rigid body, 2) a spherical visual mesh, and 3) a spherical Area that is used to attract other cells through gravity.
What am I doing wrong? What have I misunderstood?