Monday, March 4, 2013

NavTac - Log #9

Another day of working on this game on-and-off. More accomplishments!

Biggest thing since the last post, I've gotten the basic ship AI pretty much done. It can idle, patrol on a set path (with a patrol-path script I also made that manages ordered waypoints and can loop it or not), pursue and attack enemies, or retreat to a predefined location - like a repair dock.

I've also implemented a pool manager to handle objects that will be constantly instantiated... right now that means only cannon shells being fired from the ships. This will definitely help with optimization. The scripts I'm using for this were kindly provided for free by Boon Cotter over at his personal Booniverse blog. They can be found on this page.

Unfortunately, as I'm learning more about C# programming, I'm finding things I could and should change in my scripts to make them better. For example in my ShipMovement script, I use two booleans to dictate whether the FixedUpdate() function should accelerate the ship to full speed or drag it down to a halt. This means in my AI or anywhere I want to change it, I have to flip both of those, like this:
throttleUp = false; throttleDown = true;
A much better way to do it would probably be to use enumerations for it, as I just learned and am using for my AI-states in that script. That way I could just say:

throttleState = throttle.Up;
or
throttleState = throttle.Down;

Might not seem like much of a difference here. But in my AI script, I currently have that first version repeating lots of times, usually after boolean checks to see which one is currently active also. Obviously, that wouldn't be an issue with enums. For now I'm going to continue development and then go back to refining code towards the end of the project. Right now it's on an as-needed basis but I'll probably end up doing it either way.

Won't be working on it AS much this week. I have animation work that needs to be caught up on before Thursday!

No comments:

Post a Comment