i currently work on EnemyAI and try to let follow an enemy the Player.
So on, this will work, but i don't get a collision detection.
As you can see here, there are many collisions and i want the enemy walk arround this.
But i don't get it.
Only the Green Grass is sayed it is an Navigation. My Tree Construct is this:
My Code for this Event is this (the Enemy does not follow the Path, maybe you see the fail)
if Navi != null:
var path = Navi.get_simple_path(player.global_position, global_position)
Line.points = path
if path.size() > 1:
var start_point = position
var distance = MovementSpeed * delta
for i in range(path.size()):
var distance_to_next = start_point.distance_to(path)
if distance <= distance_to_next and distance >= 0 :
position = start_point.linear_interpolate(path, (distance * 5)/distance_to_next)
elif distance < 0:
position = path
distance -= distance_to_next
start_point = path
i hope you can help and understand me!