Topic was automatically imported from the old Question2Answer platform.
Asked By
MasterRN
I’m making an enemy ai who chases the player, but when they get stuck on an object, like a rock I want them to move away from it a little so they can continue chasing.
This is how I move towards my target
$Raycast.cast_to = (Target.global_position - global_position)
$Raycast.force_raycast_update()
DIR = $Raycast.cast_to.normalized()
var motion = DIR * SPEED
move_and_slide(motion)
so how do you move a point away from another point, I have no idea, thanks
Basically “AWAY” is a reversed vector, i.e. negated.
DIR = -DIR
However, you don’t need to “move away”, you need to detour obstacles. For this you need to employ pathfinding with Navigation.
Oh wow so simple xD thanks. Also with pathfinding do you need to have a tileset? because I don’t have one yet, that’s why I chose to use this tutorial A Bit Awake - News
because it didn’t rely on having a set tileset.