I’m trying to create a simple AI controller that uses waypoints and 5 animations: Idle, Walk, Shoot, Take Damage and Death.
I want the AI to travel to a way point then stop for a certain time then begin travelling to the next way point. I’ll add the rest of the script in the comments.
I’m trying to create an AI that will navigate terrain but also have the ability to stop as to simulate having a break, as well as shoot at a player. I’m not sure how to structure it into the controller script… Sorry if that doesn’t make sense @Nocktion
Okay okay. First of all if you haven’t got any kind of barriers between two way points then you shouldn’t have to use na navmeshes. If this is the case then it’s pretty simple just rotate your AI character in the direction of the waypoint and using the walk animation travel the character to the point. Then create a random value e. G. int break = Random.Range(5, 15);, start the idle animation and use a coroutine to wait ‘break’ seconds before starting movement animation again. Meanwhile in the update function get an overlap sphere with the range of sight of the AI and check if there are any enemies in the array if yes then stop the walk animation, set your enemy as a target, rotate the character towards the enemy and trigger the shoot animation. If there are multiple enemies in range then do the same except you will have to compare their distance first then use the closest one as target. And lastly if the health of you character hits zero, trigger the death animation. The case is almost the same with a navmesh except you will have to use the waypoints given by the navmeshaicontroller or whatever it is called (sorry I don’t remember it’s exact name). So that’s it. If something is unclear or you need some code, then just comment under my answer.
Happy coding!