Yes, sure. So basically the raycast is for an enemy to check if there is a cliff in front of it. The enemy is knocked back into the air and because of that, the raycast doesn't work properly, so I want to disable it.
func _process(delta: float) -> void:
#turning the enemy if the raycast to check the ground isn't colliding
if $raycast2D.is_colliding() == false:
if facing == 1:
elif facing == -1:
health = health - amount
#changing the velocity to show that it is knocked back
velocity.x = 75
velocity.y = -30
$raycast2D.enabled = false
$knockback_timer.start() #staring the timer to set the raycast2D to be enabled again
func _on_knockback_timer_timeout() -> void:
velocity.x = 0 #stop the knockback velocity
$raycast2D.enabled = true
It it suppose to stop the raycast from checking for ground when the enemy is in the air, but when I run the game the raycast is still working when the enemy is knocked back.
p.s my wording maybe weird for certain parts because English is not my native language, thanks for your time.