Enemy attacking animation won't stop

I am very new to this, first time trying this.

How do I stop the enemy from attacking when i’m not near it?

What is the expected result - enemy stop attacking animation and firing bullets and go back to walking

Explain what should happen when you run the game - player comes near enemy, enemy begins attack,fires a bullet and if player is no longer near the enemy, enemy should stop attacking and go back to walking.

What is the actual result - player goes near enemy and attack animation starts, and enemy starts firing bullets but it wont stop. It also, doesn’t start the sound on the first bullet, starts on the second bullet.

part of the text was cut off in the image for the ray cast…disregard that. Also the enemy is on a floating platform and that was the only way i could figure out how to get it to walk back and forth and not fall off the edges.

Why are you using raycast and not just checking the distance from player to enemy?

Additionally, if you have more than one enemy in the scene, you’ll need to iterate over each enemy to see if it’s within attacking distance.

How do you figure that out?

Have you tried putting the left/right objects on the edge of the platform? Maybe a screenshot of the scene in editor mode may help here.

I got it all sorted. Thanks. :slight_smile: