Missile System Integration
I have integrated the missile system and the targeting system into my jet. It is working fine, but I have yet to put a limiter on the missile firing; therefore I can fire unlimited amount of missiles, and I can fire them as fast as I can press my key, but this issue will be addressed later.
 |
| Targeting system in action. |
 |
| Fire missiles at selected target |
Speedometer
I created a floating speedometer to show the speed of the aircraft. I attached a empty object to my aircraft. I use codes to attached a GUITexture and GUIText to the empty object. The GUITexture's width and the GUIText's text is updated according to the current speed.
 |
| The aircraft is going at 30 unit / second! |
Route & Patrol
I have referred to the patrol logic in the Unity demo: Angry Bot, and I have designed a more fluid patrol system.
 |
| Patrolling the checkpoints |
- Yellow : Checkpoint and checkpoint's radius
- Blue : Connector between checkpoints
- Green: The connector that link the last checkpoint back to the first checkpoint
- Purple: The designated point for the subject
- White: The forward-orientation of the subject
In the patrol logic that is used by the Angry Bots, the patrol path of the subject is more rigid. In my take of the patrol system, I uses the radius of the checkpoints to control how soon the subject will switch to next patrol point: Checkpoint with larger radius will make the subject switch to next checkpoint sooner.
Furthermore, I take it a step further by using a smooth rotation to make the subject to follow a smooth path when patrolling the route. At each Update(), the subject will try to rotate to its designated point ( in layman's term, aligning the white line with the purple line ), but I limit how far the subject can rotate, therefore the rotation to realignment is a smooth and slow process.
This system will be used for enemy AI craft in their idle state. I have think of some other possible application in this system, but I will not be looking into it for now.
Ray cast
Ray casting is a process of determining whether a ray intersects with any object in 3D space (
further reading); Common applications of ray casting are:
- FPS: Firing a gun will initiate a ray cast, if the ray intersects any enemy, damage calculation is then performed on the enemy
- Enemy AI's vision: Enemy 'sees' the player by pointing a ray cast at the player, if the ray cast hit a object that is not the player, then the enemy does not 'sees' the player.
I have used a wrapper code to simplify the usage of
Physics.Raycast in Unity:
 |
| RayCheck.js |
The Check() is applicable in identifying obstacles and Within() is applicable in determining whether a object is within range of a specific weapon. I will be putting in enemy-vision + cover-system within 2 days.
- Red: Where we are looking at (Field of vision)
- Blue: Subject is within the range of the Field of vision
I will not go into details on how ray-cast works and how my wrapper code works; but I want to say this wrapper code will simplify the ray-cast process and it will serve an important role in my enemy AI system.