#Pathfinding Issue

18 messages · Page 1 of 1 (latest)

deft owl
#

Hello everyone I am having trouble figuring out how to make my pathfinding for my enemies work. So far every time I tried to fix it I just broke it further and I didn't found that helped. The current issue is the enemy as far as gameplay goes the enemy is going to the opposite direction the player is. Anyone know the cause?

chrome prawn
#

direction calculating should with subtractions

#

ru trying to make the enemy follow the player?

#

in that case it shuold look like this:

Direction = (player.global_position - enemy.global_position)

#

also u dont rly need to do this as godot has a function called "direction_to" that does it for you
so it would look like this: direction = global_position.direction_to(player.global_position)

chrome prawn
deft owl
#

Well the thing is that I really wanted the enemies to avoid obstacles so that was the reason I wanted to use pathfinding. Any way to add the pathfinding so the enemy can for example avoid trees?

chrome prawn
#

and their characterbodies are aligned with their respective icon

chrome prawn
chrome prawn
# deft owl yes

You can try using NavigationPolygonInstance2D if you aren't already

#

and with it you could mark the ground and stuff that the enemy CAN move on, js make sure you're not makring the trees so the enemy knows it should go around it/avoid it

#

Hope im understanding this correctly :)

deft owl
#

how to get the path that enemy would use

#

I FIGURED IT OUT!

chrome prawn
#

Oh really?

#

Well done, may I know what you did?