'How to attach AI components' (Ver.3.0)

Please feel free to contact me if you have any questions.
shopmaster@chobi-glass.com
http://chobi-glass.com/Unity/index.html



*** Outline ***

This section shows how to attach AI components to the tank made in the previous steps.

AI tank has three AI objects "AI_Core", "AI_Eye" and "AI_Hand" in it.

Also AI tank has "AI_Settings_CS" script in the top object in order to store the temporary settings.
"AI_CS" script controls the behavior of the tank in combination with the "AI_Settings_CS" and the "AI_Hand_CS" scripts.
(Note.)
AI tank cannot choose the target itself.
The target of each AI tank is chosen by "AI_Headquaters_CS" script in "Game_Controller" object in the scene.




*** How to attach AI components ***

(1) Attach "AI_Core" prefab.

You can find the prefab "AI_Core" in the "Tank_Components" folder under the "Prefabs" folder.


Drag and drop it into the "MainBody" in the Hierarchy window, and make sure that the "AI_Core" is placed under the "MainBody" as a child.



(2) Adjust the position of the "AI_Eye".

The position of "AI_Eye" is very important for this AI system.
If the the position is too low, the AI cannot detect any target because the ray cast for detecting the taget is always obstructed by its turret.
In the case of "Karl" in the demo scenes, the "AI_Eye" is set at 100 meters above the body in order to be able to detect all the targets in the scene.

Also the collider of the barrel might obstruct the ray cast from the "AI_Eye".
Please remove the collider from the barrel when the tank has a long barrel such as "Firefly".

In this tutorial, we can skip this step.


(3) Adjust the position and the scale of the "AI_Hand".

You can see the "AI_Hand" as a translucent box in front of the tank.
Adjust the position and the scale so that the box does not touch the tank.
In this tutorial, we can skip this step.



(4) Attach "AI_Settings_CS" script into the top object.

You can find the "AI_Settings_CS" script in the "C#_Script" folder.


Drag and drop it into the top object of the tank in the Hierarchy window, and make sure that the script is added to the top object in the Inspector window.



(5) Save the new AI tank.

Save the new AI tank as a new prefab referring to 'How to save a new Tank Prefab'.


(6) Test the behavior in the runtime.

Configure the AI settings referring to 'How to use AI Tank', and test the behavior in the runtime.



We have now completed the tutorial "How to create a new tank".

We have finished three kinds of KV-I tanks, with "Physics_Track", with "Static_Track" and "Scroll_Tracks", and with AI components.

Try to use them in the battle scenes.

Please feel free to contact me if you have any questions.
shopmaster@chobi-glass.com
http://chobi-glass.com/Unity/index.html