HELP…My enemy sprite is a character facing to the right, spawning from random places in the viewport.
I need my sprite to flip towards the left when it spawns anywhere in the right half of the viewport.
This is how it looks in the 2D window
This is the script I’m using for the enemies
func _on_enemy_timer_timeout():
var enemy = enemy_scene.instantiate()
var enemy_spawn = get_node("EnemyPath/EnemySpawn")
enemy_spawn.progress_ratio = randf()
var direction = enemy_spawn.rotation + PI / 2
enemy.position = enemy_spawn.position
direction += randf_range(-PI / 4, PI / 4)
enemy.rotation = 0
var velocity = Vector2(randf_range(150.0, 250.0), 0.0)
enemy.linear_velocity = velocity.rotated(direction)
add_child(enemy)```
Sorry for the broken English. D: