Problems with enemy programming [DOOM LIKE game]

Godot Version

Godot 4



I’m starting in development and games with Godot 4.
I found a really cool tutorial by Marcial Lincoln about a clone of Wolfenstein 3D, but I’ve been having difficulties because the tutorial was made in version 3.5 and I’m reproducing it in version 4. I managed to resolve several bugs that arose during development, but there are two things I couldn’t resolve.

1- An identification/declaration error;
2- Some tiggers that were made with “yield” and I can’t make them work with “await”

Can anyone give me a light?

I’ll leave the enemy code where I find these problems to better illustrate

extends CharacterBody3D

enum StateMachine{ IDLE, WALK, SHOOT, DEATH }
@export var health := 15
@export var speed := 7
@export var distance_follow := 20
@export var distance_shoot := 10

var state = StateMachine.IDLE
var motiom = Vector3()
var death := false
var shooting := false
var target = null

@onready var animated_sprite = $animated_sprite
@onready var ray_cast = $ray_cast
@onready var collision = $collision
@onready var hit = $hit

#@onready var player : CharacterBody3D = get_tree().get_first_node_in_group(world)

func _ready():

func _physics_process(_delta):
#motion = Vector3

match state:

if _get_distance_player() <= distance_follow:
state = StateMachine.WALK

velocity = ray_cast.cast_to.normalized() * speed

if _get_distance_player() <= distance_shoot:
state = StateMachine.SHOOT

if _get_distance_player() > distance_follow:
state = StateMachine.IDLE

if not shooting:

if _get_distance_player() > distance_shoot:
state = StateMachine.WALK

if not death:
death = true"death")
collision.disabled = true


func _get_distance_player() -> float:
ray_cast.cast_to = to_local(target.translation)
if ray_cast.is_colliding():
var body = ray_cast.get_collider()
if body == target:
return translation.distance_to(target.translation)

return INF

func _shoot() -> void:
shooting = true"shoot")

await animated_sprite.animation_finished"idle")
shooting = false

func apply_damage(damage:int) -> void:
health -+ damage
if health<=0:
state = StateMachine.DEATH
await get_tree().create_timer(0.1).timeout

Does anyone know what I’m doing wrong?