|Attention||Topic was automatically imported from the old Question2Answer platform.|
I have some code to move a kinematic body 2d along an AStar path,
the body is provided with the path points as a Vector3 which is how AStar handles them.
I would expect the character to move to the right, however it pretty much always looks off in the wrong direction and heads towards the top left corner.
What am i doing wrong…
var moveSteps = [Vector3(60,0,120),[Vector3(90,0,120),[Vector3(120,0,120),[Vector3(150,0,120),[Vector3(180,0,120),[Vector3(210,0,120)] var nextMoveStep = Vector3(30,0,120) func _physics_process(delta): var pos = nextMoveStep if isMoving: var vel = Vector2(1,0) var posV2 = Vector2(pos.x,pos.z) print("to Pos: "+str(posV2)) print("CurrPos "+str(position)) print(position.distance_to(posV2)) print(rotation) look_at(posV2) var rot = rotation print(rot) vel = vel.rotated(rot) vel = vel * speed move_and_slide(vel)