Working more into the Game AI’s today’s session was focused around working with the Third Game AI. The behavior of this AI is to follow the player whenever he is not looking and slowly get closer and closer.
This AI is composed of 3 scripts, Chase Script, State Machine Script and Player Movement Handler.
The Chase Script, is basically just telling the AI to move to the player position.
The State Machine hold that current states that are available, working together with the Player Movement Handler, the state machine controls when the states will change. By using the player positions x position.
Player Movement Handler is where we send information on the players movements to the State Machine, the AI reacts to the movement of the player, this was for the testing stage, but now I want the AI to react to the way the player is facing, so if he faces towards the AI it won’t move, but if the player shows his/her back to AI it will move towards the player.
I tried altering the code in the Player movement handler, in an attempt to get the facing position to work as previously discussed, I don’t know if I’m just having a brain block, but anyway, taking a break from that, I started working on a new script that could potentially do the trick and it did, however this script is super small and does require any kind of state machine handler.
New chase script, this script is pretty basic, the Game Object AI Three which is the current AI being worked on, chases the players transform position, however the two On Trigger functions, using the Looking tag, the AI will not move if it is in the radius of the box collider that is attached to the player object, this is because the box it self holds the Looking Tag, so when the AI is inside the radius of the box collider it will not move, but once the player has moved outside of that range, the AI is free to move towards the player.
I found that this version of the chasing script worked particularly well, however I would of liked the AI to move a bit better around the maze, as it is currently just moving into walls, more development will be required into this one, but right now the simplicity of this AI is perfect for a prototype.
Also, I realized the other day that the maze that was created is way to big !!! Downsizing it, is going to be necessary, but that is a good thing, VR games require a lot of optimization, so decreasing the amount of assets or objects being used will help with the end result of development, loading speed, latency etc.