Thursday, November 15, 2012

Projectile Prediction

For this week, I've improved the design of our projectile system.  Previously, the projectile only fire to the player's position when first fired.  This, of course, wouldn't be very logical as one wouldn't fire where he was, but rather where he was going.

Thus, I added a prediction system for the AI to use that allows the AI to gather the player's forward orientation and predict where the player will be in x amount of seconds (it is currently set to about 1 second). The implementation was a bit complicated, and nailing down the precise formula was difficult (3D space is infinitely harder to work with than 2D space).  However, I was pretty happy with the results at the end. Now, if the player runs in the same direction when the AI fires, the player will be hit (with some error built in for good measure).

In addition to that, I've worked on re-modeling the projectile class as not just a part of the enemy class, but rather an ability that can be extended from and used for both AI and player alike.  I've implemented the basics of how the class will be set up, but I need to do some pair programming with our other ability programmer, Blake.  We need to get together and solidify the ability class, so that it properly extends to both the player and AI in a reasonable manner.  Hopefully, we'll have a robust ability class that will serve well until the end of the project.

Katana Model


I've taken some free time to do something a little extra for this project.  Since the basis of the game is Ninjas vs. Samurai, I took it upon myself to model a little katana for the Samurai to use.  Here are some pics of what I made.
















I used a tutorial to help me out with the basics whilst adding a little flavor of my own in the blade and hilt.  I especially like the hilt design.  It's still a bit primitive, but it should work for our alpha build.  Just a little something I thought would be fun to do.

Projectile Mechanics

I implemented a system that would allow the guards to fire projectiles at the player. To start, I simply needed to launch a simple projectile. Thus, I modeled a system that let the enemy take in the player's position, create a projectile at the enemy's position, then propel the projectile towards the player's position every update cycle with a given velocity. A relatively simple function, so I expanded the functionality a bit.

First, I developed a projectile manager that would handle any and all projectiles that a guard may use. This would provide a method to create and delete any projectiles that belong to a particular guard. 

Second, I implemented a hit detection method for the projectiles. Every projectile would check, every update cycle, whether any of the current player's were colliding with it. The function would return true if a player was colliding with it, and false otherwise.

As of now, it works pretty well.  I added a timer so the AI would only fire a projectile every x seconds, and it seems to work well in testing.  I did have some problems manipulating the angle of the projectile at first, but I worked it out to face properly.  I'll be refining this system to include all types of projectiles, and to compute smarter paths over the next week.

Monday, October 29, 2012

AI Mechanics

I was assigned to help work out the basic AI for our enemies. I assisted in this in two ways.

First, I helped research on the A* path finding algorithm. It was vital for our AI to find the player efficiently, so Ron and myself looked into whether this algorithm would work well. Fortunately, it did seem to fit inside our idea for the game, so I found an implementation of the A*, and sent it to Ron to tweak it to our game.

Second, I implemented an algorithm for the AI to use once it lost sight of a player. I went about this by thinking what it meant for the AI to be searching. I couldn't allow the AI to just automatically know where the player is. Thus, as a basic implementation, I simply let the AI choose a direction, and pursue in that direction for a given time. Then, after that time expired, I would have the AI choose another direction to check. 

Our team hadn't finished the guard AI for the time, so I tested this using the player.  Fortunately, the player moved in the way I predicted when I assigned this to a movement controller.  

Ninja Theme

I've taken some free time to compose a theme for our game.  I arranged it to be Japanese in the instrumentation (Koto, Shamisen, Shakuhachi). However, it has a driving beat as well to keep it interesting (I see this as a good first level piece).  Have a listen if you want.  Enjoy!

*Update*
The latest version has been loaded up now, and hopefully should have, at least, an increased awesomeness of 150%!  I added a little to the background to fill out the theme a little, and added a little electric guitar to spice it up a bit!  This was to blend a little Western flavor into the game since this game is about the player's avatar becoming a ninja; thus blending styles a bit seemed appropriate.