For this weeks work I started on adding the pathfinding for the AI so that he can patrol around the map. The pathing system works by using the navMesh to create pathable areas of the map and then I tell the navMeshAgent to move around to specific way-point markers positioned around the scene. I contemplated just writing the Vector3 coordinates into the inspector however this was awkward for trying to get the exact positioning that you want. However as I want the AI to be as easy as possible to set up I am still looking at different ways that could improve it and make it more user friendly. Currently when the AI sees the player he will run towards him (Nothing will happen when the AI touches the player) and when he loses sight of the player will go back to patrolling. If he becomes suspicious and thinks he saw the player he will move towards where he though the player was. This will work for sound as well but I will change this to work with both once I link the 2 mechanics together at a later date.
So far I haven't encountered too many problems when creating the AI. However one problem that I did encounter this week was that I couldn't get the AI to move to any position when calling SetDestination(). I went onto the Unity scripting reference (Unity, 2017) to see if there was a different function that might work but nothing that I found on there worked either. I create a new script and a game object with just the necessary code to move it and it worked. I tried debugging my script to see what was stopping it from working but nothing seemed to work. I then removed the navMeshAgent from the AI game object and placed a new navMeshAgent and things started to work. The only other problem I have noticed so far is that the sight raycast is shot from the players foot which I have mentioned before.
For next week I will be finishing the pathing system and looking into ways that I can alter the current way-point system to be more user friendly and make it easier to set up patrol paths for your AIs.
References
Unity (2017) navMesh documentation. Available at: https://docs.unity3d.com/ScriptReference/AI.NavMesh.html.
No comments:
Post a Comment