How do you fix sprite flipping in Path2D Diagonally

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sugor

I follow the tutorial of kidscancode: https://kidscancode.org/godot_recipes/ai/path_follow/
where it uses a kinematicBody2D to track the points of a path2D with using pathfollow.
The problem is when I’m flipping it is fine as long as it is Horizontal and Vertical, but when the entity is about to move diagonally its flipping is messing up.
First I tried to sprite flip with
entity.flip_h = velocity.x < 0 , which I find it wrong. Then, I tried to use a different method:
entity.flip_h = position.x < patrol_points[patrol_index].x , which this is the point of the path2D it works properly with H and V too but diagonally, No. How do keep the flipping consistent without any jaggy flipping.

edit: Additional: when I tried to print the velocity the velocity isn’t consistent too.