Wednesday, April 18, 2012

Firing Guns Work!

So, I successfully completed the script to fire guns, and it is fully functional.  I made a few improvements like creating a list of spawn points during start up and using the list during the firing procedures.  The previous prototype required that each spawn point be defined (via global variables) and each spawn location be included in the code.  The old flight control and fighter AI routines could only handle two bullet spawn points (pretty much one on each wing).  The new fire control script can handle any number of spawn points. 

Now that I got step one out of the way (see previous post).  I needed to sit down and map out the missile firing sequence.  Here's the basic process:

Step #1

The missile firing process requires the player to lock onto a target.  When a player mouses over an object, the game checks the faction of the object.  The lock on process won't function on members of the same faction which will involve a change cursor routine with a "Can't Lock" looking cursor. 

As long as the factions are not the same, the script will check for eligibility.  Basically, the target has to be within a certain range and firing cone (probably 30 degrees in front of your ship).  This will force a change to the mouse cursor with a "I'm locking onto to a target" looking cursor.

At which point, we need to check if the target is already being locked onto.  If the target is new, the scipt starts a timer process which will involve starting a 60 second timer and recording the target under acquisition.  If the target is already being acquired, then we just continue with the timer (and update the U/I with the countdown.

Once we get a lock, we place a permanent "locked on" cursor over the target and load the object into the missile target variable. 

This should complete the "locking on" process.

Step #2

After the lock on process, the player can fire a (or multiple) missiles at the target.  This can be accomplished by pressing the right click mouse button.  Once clicked, a class will check the missile firing timer (make sure that we're not firing missile too fast).  As long as everything is good, it will spawn a missile at the missile spawn point(s) and decrease the missile load by one.

I've already completed the variable declaraction section for the missiles.  Here's the documentation section with a list of variables, methods and procedures. 

Now I just need to create the code...

I did run into a problem getting the bullets to spawn correctly.  Unity3D has a great resource in Unity Answers.  Here's my question and answers:

No comments:

Post a Comment