After u created your Animal AI in the last section, you will see few scripts and components added to your animal Game Object in your scene. We will learn how to use them in this section.
Be sure to read all of these tabs below to make your AI work perfectly!
Editing the "Navmesh Agent"
You will only need to touch the radius and height of your Navmesh Agent.
Adjust the radius & height variables so that the Navmesh will fit your animal model.
The Whole model should be inside the Green Preview of the Navmesh Agent. Example:
Editing the "Collider"
Normally, the system adds "Capsule Collider" to your animal automatically. But if you want a sphere or box collider it is fine too! You can delete the capsule one and add a box or sphere collider too! Just make sure that your animal has 1 collider.
Go to the "Capsule Collider" on your Animal GameObject.
Adjust the collider so it fits your animal model perfectly. Example:
This is a really important part, you don't need to set your settings the same as I do. Just adjust them as you like until you find the perfect settings for yourself!
Your AI won't work if you don't do the ANIMAL AI ANIMATIONS tab!!
Go to the Player Resources tab and make sure your player is assigned or if your player spawns after the game starts, you select Setup Player On Runtime and put your player's tag!
Here is a quick explanation of the most important variables:
Animal Properties Variables
Explanations
Animal Type :
The animal's type that it will be.
Stop Follow Distance
The pet's too close to player distance.
Start Run Distance
The pet's too far to player distance.
Stop Flee Distance
The coward animal stop running away distance.
Animal Settings Variables
Explanations
Don't Disable Collider
The animal's collider will stay after death.
Can Run In Wander
Can the animal run in the wander/patrol state?
Animal Walk Speed
The animal's walk speed.
AI Can Run?
Can the animal run?
Animal Run Speed
The Animal's Run Speed.
Min/Max Idle Length
How long can the animal stay in the idle state?
Disable Child Colliders
Will disable the child colliders if there are any.
Part #2 of the variable explanation:
What is the difference between Line Of Sight & Trigger-based detection?
1- Line of Sight detects the player if only it is in front of the animal AI.
2- Trigger detects the player if the player is in its detection distance radius.
Navmesh Settings Variables
Explanations:
Acceleration
The animal's navmesh acceleration.
Base offset
Animal Detection Variables
Explanations:
Detection Type
How will your AI detect the player?
Head Transform
The head transform is used for the "Line Of Sight" detection.
Detection Distance
The max distance AI can detect the player
Detection Angle
The angle that the Line Of Sight system can detect the player.
Animal Attack Variables
Explanations:
Enable root motion on attack
This will enable root motion on the attack
Attack Distance
Distance to attack
Max Damage Distance
Max distance the animal can damage the player
This part is on the next page. Click the button below to continue reading!
The base offset of the AI (I recommend checking this )