- Home /
free roaming enemy ai
I am making a small arcade survival horror game where players last as long as they can. Anyway I want to make an enemy ai similar to the SA-X in Metroid Fusion where it allows the enemy to roam around wherever once then run towards then attack the player when the player is spotted, how can I accomplish this?
This may have been asked already but I thought I might check first just in case
Answer by YiYiBaBa · Jan 21, 2019 at 06:50 AM
If it is me, the first thing to consider is what kind of navigation method the enemy USES for path navigation.One is the Astart algorithm, and the other is the navigation provided by Unity, which assigns multiple points to the path and marks them as 0,1,2,3, and so on.Using Random, the Random number is used to match the position of the point.Allows enemies to randomly move to a specified point.The enemy can then be given a fan Angle to calculate whether the player has been spotted Vector3 targetDir = targetPlayer.transform.position - transform.position; Vector3 forward = transform.forward; float angle = Vector3.Angle(targetDir, forward); if (angle < 30.0f) { //TODO Attack } I hope my answer is helpful to you
Your answer
Follow this Question
Related Questions
Enemy AI Patrol Points Array Index Out of Range? 2 Answers
Enemy AI problems 2 Answers
Is the Player Being Looked at 1 Answer
Enemy keeps moving in one direction. Help pls! 2 Answers
How do I make a 2d enemy change direction upon hitting a wall? 1 Answer