- Home /
Custom AI issue
Hello,
I have created a custom AI for enemy which follows the player when it looks at the player. I am using Raycast for the above functionality. It works fine but when the player is behind the wall or some object then the enemy stops following the player which is obvious because the enemy cannot see the player.
So is there any way I can make the enemy follow the player.
Or is it better to use the Unity Navmesh agent. But my game enviornment is large with bumps, walls, building with lot of other things. Is there any performance issue if I use Unity Navmesh Agent instead of my custom AI script.
Any suggestion, help will be appreciated.
Thanks
The Unity Navmesh is pretty optimized, so you can of course use it. But if you have alto of 'followers' I would recommend limiting the the Navmesh following to a certain area/distance around the player.
But to follow your initial approach (for what reason ever):
You could put your target (player) on Layer (e.g. PlayerLayer) and raycast only against the specified Layer. When doing so, your enemy does not stop following when in front of road sign or what ever. But you will come across some situations this kind of AI is looking pretty bad (As you said: when there's a wall in front). :)
Hi,
I was looking at Angry Bots project in unity which I think is also not using the Unity Navmesh and are using custom AI script to follow the player so I thought that navmesh causes performance issue.
Next about my AI script, when it sees the player it follows the player but when my player is behind the wall it stops following him because ray from enemy cannot hit the player. But the main point is can I make the enemy make its own path like unity navmesh agent.
or maybe I should use Unity Navmesh and modify it as per my needs.
Your answer
Follow this Question
Related Questions
Nav mesh agent position 1 Answer
NavMeshAgent not crossing over certain tiles 0 Answers
when I add a navmeshagent to an object and start the game, the object is moved ,anyone know why? 0 Answers
can Not open Window > Navigation 2018.2 1 Answer
How would I simulate a rectangular Nav Mesh Agent? 0 Answers