Sep 9, 2012

Update: HUD and EMP


I have made little progress on my Enemy AI. I will revise my solution to the system again, I might scrap the whole thing and rebuild it from scratch. For now, my current version the enemy flight AI will be able to to three things (in order): pursuit, evade obstacle and evasive flying. Most probably, I will not make it perfect as I do not need a plane to fly through a tight obstacle course perfectly. I just need them to be able to engage their enemy and be able to evade obstacle smoothly. After I completed engage and evasion functionality, I will work on the evasive flying segment.

Anyhow, I made some good progress in my game mechanism branch. I upgrade the speedometer (the previous 3D floating speedometer looks horrible when I look back at it), put a limiter and GUI bar on the afterburner, add in an EMP burst defensive weapon (which will destroy all missiles within range, including my own), and add in the GUI for the EMP.

New GUI
EMP charged and ready
EMP is charging

In the EMP, I animate a sphere and scale it from small to large, so the sphere will act like an explosion. Previously, I have built in some codes in my missile to explode whenever they touches something; I did some quick addition and now the missile will explode whenever it is in the range of the EMP field. I learn something new as well, I now know that I can call function from my animation via event in the animation system, I called Die() of my EMP field at the end of the animation to delete the EMP field from my scene.
Building the EMP


Sep 1, 2012

Multiple Primary Weapon

I have rebuilt my missile launch system, and did some slight modification to my targeting system; Now I have a multiple primary weapon system. One primary weapon are active at one time, I can switch primary weapon by pressing A.

There isn't much progress in the enemy flight system. As I have suspected, it is a very complicated to code in a AI to fly through obstacle. What I think that is going to happen right now is that I will have 2 branch of development, one solely focus on the enemy flight AI while the other will focus on the miscellaneous aspects of the game.

Primary Weapon No.1 is selected

Firing primary weapon no.1

Switch to primary weapon no.2

Firing primary weapon no.2

Aug 31, 2012

Radar and Spawn

I have improve the targeting system with the following updates:

1. 3D Radar

 I have spent a short time to built a simple 3D pointing system 2-3 weeks back and now I have merged it under my targeting system. When the selected target is in view, the 2D lock system will work; if it is not in view, then the 3D pointing system will kick in to show the player where the target is. Standard stuff in jet combat game, there is nothing much to it.

I am thinking of using this system to warn player about incoming missiles or item/location of interest, but that is for another day in the coming future.
Target Selected

The radar will point to the target when it is not in view


2. Dynamic Target Addition and Marking

I am now able to add new target in run-time dynamically.

In AddTarget(), new target (which currently are of type Transform, this be will change soon) is added to the list in the targeting system; then a new marker is instantiated and attached to the target.


3. Spawn

To test the dynamic target addition and marking mentioned above, I have write a simple spawning script to spawn gameObject in the scene, the spawning mechanism then call AddTarget() using the new gameObject as parameter. As a result, the targeting system will recognize the spawned object as a active target and a new marker will be attached to it.

This spawning mechanism is so simple and effective, I think I will be using it in spawning enemies.
There are no active targets in scene.
Spawned targets are all marked properly.

Splash

 I will be working on the following for the weekend:

  • Completing the targeting system
    • Switch to 3D pointer when the selected target is out of view
    • Target management (flexible adding and removing list of targets)
    • Dynamic adding of markers when new target is listed in the system
  • Basic flight AI
Meanwhile, I have put up a quick screen splashing effect, this is to make player to avoid flying into debris field, this is still very basic, there is a whole list of improvements waiting to be implemented this visual feature:

Cube has not enter the splash zone (Spheres)

The cube entered the splash zone multiple time.

Aug 26, 2012

Updates: Missile & Raycast

Missile System
I have code in the limiter for the missile system. Now the missile system have limited amount of ammunition, and it has a reload time for each missile slot.
Bottom right is the missile display
I also use a texture and text to display how many missile I have and the status of the missile slot.

Raycast
I have built another function into my RayCheck class to check whether an object is in view and not behind any cover.

The Cube 'sees' the Sphere

The Cube does not 'sees' the Sphere.

Missiles, Speedometer, Patrol and Raycast

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.


Aug 21, 2012

Aim, Lock and Fire!



I am successful in combining both the ejection system and the targeting system. It will working well so far, but I will be testing it for another day or two. I take serious precautions on this as this system will form the basis for all the weapons in the game, I will make sure that these codes are working properly and they are both adaptable and reliable. 

For now, this is what I got:
Lock-on and fire away!

Step 1: Lock-on a new target;     Step 2: Fire;     Step 3: Repeat Step 1 and 2

Missiles fired will fly blind if no target is locked on (Idle missile have no ring-HUD attached to them)