![]() |
| 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
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 |
![]() |
- Red: Where we are looking at (Field of vision)
- Blue: Subject is within the range of the Field of vision






No comments:
Post a Comment