0 votes

Hello everyone,
I was trying to debug my code where some units could move and attack because with around 60-70 units it started to run at a very lwo framerate.

Sadly, I commented out most of my code and discovered that it was still running very slow with only the movement inside the units physics process.
To make you understand better, here is the code and the profiler:

func _physics_process(delta):
  if self.isDead:
      return

  if isMoving: # always true, since I commented the part of the code that could set it to false
      var vector = ( self.destination - .get_global_position()).normalized()
      myUnitBody.move_and_slide(vector * movementSpeed)

The profiler

I was not able to understand why, with just that code and 60-70 nodes, I get this huge frames drop while I've read of people that manage to fit 500+ units without any issue.

Thank you in advance.

asked Apr 6 in Engine by Gargarensis (12 points)

What kind of node are these units? KinematicBodies or something else?

They are KinematicBodies with 2 areas, an healthbar (which is a subscene) and a CollisionShape2D

Try commenting all the code inside the _physics_process method, then try uncommenting lines slowly.

What processor do you use? I can imagine something like a 2014 mobile Celeron not being able to handle this many nodes.

I am using an Intel Core i7-4510U

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.