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[0])
if distance <= distance_to_next and distance >= 0 :
position = start_point.linear_interpolate(path[0], (distance * 5)/distance_to_next)
break
elif distance < 0:
position = path[0]
distance -= distance_to_next
start_point = path[0]
path.remove(0)
Maybe you can me help with this:
I have decided to change my movement to an gridbased movement. I don’t get it to change my navigation to this movement and don’t found any tutorial for that.
Do you have a idea how to change this?
My Current Movement without Navigation
var Real_Walk_direction = Walk_direction * Constant.TILE_SIZE
if Real_Walk_direction != Vector2.ZERO:
CollisionDetiectionSnap.cast_to = Real_Walk_direction
CollisionDetiectionSnap.force_raycast_update()
if !CollisionDetiectionSnap.is_colliding():
SmoothAnimation.interpolate_property(self, "position", position, position + Real_Walk_direction, 1.0 / Speed, Tween.TRANS_SINE, Tween.EASE_IN_OUT)
SmoothAnimation.start()
rotzend | 2020-12-18 11:18
Its my solution. (Id never say it`s the only one. But I have no idea how to change your code. Sorry