So, I have some zombies, which their default sprite is them looking left (Ignore the glitches):
https://gyazo.com/52006a1138ed076b3519d39d864de2aa

However, when I go to the left of the map, zombies are looking the other way:
https://gyazo.com/324329e639791740e274f21b421627b3

Here's the script to one of the zombies, they almost have the same script btw:

``````extends KinematicBody2D

const GRAVITY = 60

var speed = 0.5
var velocity = Vector2()

export var ZombieSpeed = 1500

export var Smoothness = 0.2

set_fixed_process(true)

func _fixed_process(delta):

var direction = (target.get_global_pos() - zombie.get_global_pos()).normalized()
velocity.y += GRAVITY
#move(direction*speed*delta)

var motion = velocity * speed * delta

motion = move(motion)

velocity.x = lerp(velocity.x, ZombieSpeed * direction.x, Smoothness)

if (is_colliding()):
var normal = get_collision_normal()
motion = normal.slide(motion)
velocity = normal.slide(velocity)
var collider = get_collider()
move(motion)

if (collider.is_in_group("Bullet")):
queue_free()
print("Zombie3 Killed!")
if (collider.is_in_group("AutoKill")):
queue_free()
print("Zombie3 Killed by Boundry!")
``````
in Engine

You can flip their sprite when their direction changes, like this:

``````var sprite = get_node("zombie_sprite")
sprite.set_scale(Vector2(sign(direction.x), 1))
``````

Note 1: while it would work, you don't need to do this every frame in `_process`, only when the direction changes.

Note 2: don't scale the body, as it may have unwanted side-effects (as described here https://github.com/godotengine/godot/issues/12335)

by (28,966 points)

That doesn't seem to work, it just sets the zombies in one position.

Oh Oo but that code isn't setting the position of the zombie sprite at all. It really flips the sprite horizontally by setting a scale of -1 if direction is left, and a scale of 1 if direction is right. Isn't this what you wanted? Or did I miss something? What is your node structure?

Ok, so is this doing the flip correctly?

``````var sprite = get_node("CollisionShape2D/PlayerSprite")
sprite.set_scale(Vector2(sign(direction.x), 1))
``````

``````- Zombie