character not flipping properly

if direction > 0:
animated_sprite.flip_h = false
collision_shape_2d.position.x = -10
elif direction < 0:
animated_sprite.flip_h = true
collision_shape_2d.position.x = 10
so I’ve had to implement this code to make sure the collision shape and animated sprite flip on the same pivot, but I didnt think I had to do that, was wondering what’s going on. In animated sprite node in offset I have centered clicked.