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?
#Pathfinding Issue
18 messages · Page 1 of 1 (latest)
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)
oh and uh make sure their offset is set to 0
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?
and their characterbodies are aligned with their respective icon
Im assuming you alrdy have Navigation2D in your scene correct?
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 :)
yes! I just want to know to use nav_agent in code
how to get the path that enemy would use
I FIGURED IT OUT!