0 votes

My project is a 2d topdown game with a lot of enemies, and my move function that uses getsimplepath and tile navigation is consuming a lot of performance.

Here is my code:

var point = 0

func move():
    target = navigation.get_simple_path(global_position,GameManager.playerNode.global_position,false)
    if global_position == target[point]:
        point += 1
    motion = (target[point] - position).normalized() * moveSpeed

This function is running on physicsproccess(delta)

asked Jul 13 in Projects by Jeff3301 (12 points)

ya try not to do it each time/frame... only when path needs to change. if click or input or etc

1 Answer

0 votes

pathfinding is generally expensive.

Don't recalculate the path every frame, do it once per second or only if the player
had moved a certain distance

answered Jul 13 by brainbug (268 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.