Sunday, 29 January 2017

Pathfinding

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.

Saturday, 21 January 2017

New Milestones

After going back to my old project milestones I have updated it to accurately show what I will be working on going forward. After updating it I had several weeks worth of time where I had no work planned so I decided to look at some new features that I could add to improve the AI. I started by looking at some of my original resources that I used when creating my brief to see what features people spoke about. I also went onto some games which I think have good AI such as Dishonored, Far Cry and Borderlands. One thing that I noticed when doing this was that I ignored what the AI will do once it is in its alert state and reaches the player. I've decided that I will be adding the option to select what type of weapon the AI has which will alter how close it will try to get to the player and when it will try to attack you. This means I will have to create the shooting system as well.

Currently I plan to add these different weapon selections:

Sniper:
Long range
Low attack speed
High damage
High accuracy

Rifle:
Medium range
Medium attack speed
Medium damage
Medium accuracy

Shotgun:
Close range
Low attack speed
High damage
High accuracy

Melee:
Very close range (Touching distance)
Low attack speed
High damage
High accuracy

I have yet to plan what distances count as 'long', 'medium' and 'short' (This also hasn't been done for the attack speed, damage or accuracy)  as I will be doing this once the mechanic has been programmed in. I will program a system that will allow me to quickly iterate and make changes to the variables and figure out what is the best for each weapon type.


Updated milestones:


Sunday, 15 January 2017

Finished hearing

After finishing this weeks work I have completed the hearing system for the AI character. This means that the character now can hear how much noise the player is making and depending on how far the player is from the AI he will be able to react to it when his reaction has been programmed in. I will be play testing at a latter date to figure out how far the AI should be able to hear. I have continued to comment my code and have tried to make it all efficient and easy to read.

Now that I have completed the hearing this week it leaves me 3 weeks ahead of my original project milestones. As I am very far ahead of my milestones I plan to look through and review all of my future milestones next week so that I can accurately view where I am in my project. I will also look at how much time I have left over once I have adjusted my milestones to see if there are any additional mechanics that I can add in the time that I have spare.