I am using Godot 3.2 for a 2D project, and running a script for an enemy to change the direction (flip_h) when is colliding with the walls, however, when the enemy collides with the wall or another enemy the enemy change also the direction.
The code I am using is working only when collides for the first time (ONCE), after that isn't flipping the direction any more, any ideas?
func _ready() -> void:
_velocity.x = -speed.x
$enemy1.flip_h = true
func _physics_process(delta) -> void:
_velocity.y += gravity * delta
_velocity.x *= -1.0
$enemy1.flip_h = false
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y