Add a visor to the enemy so we can see where they are looking
Set the dimensions as shown
Set the position as shown
Add a New StandardMaterial3D
to make the enemy look at the player
create a new function called look_at_target
create a variable called adjusted direction
remove the y component of the direction
look towards the position of the player
In the physics process function
set the enemy to look at the target
represent the enemy attack
for now, simply print "Attack!"
Add an export var to store attack range
Move the timeline to 0.2 seconds
positon to x: 0.0, y: 0.5, z: 0.6
scale to: x: 1.5, y: 1.5, z: 1.5
Move the timeline to 0.5 seconds
position to x: 0.0, y: 0.5, z: 0.5
scale to x: 1.0, y: 1.0, z: 1.0
We can even get our animation
to call our attack function
Now choose the Enemy Node
Move the timeline to 0.2 seconds
Right-click on the Functions Track
Now choose the attack function
Finally, in the enemy script
and is within attack range
play the attack animation