Friday, February 15, 2013

Pathfinding

I need to be able make my players move from point A to point B, avoiding any objects on the way. This is basic pathfinding. Pathfinding is one of those simple features that seems to be difficult to do properly. There are plenty of games that just don't quite get it right. Taking this into account, I knew I wouldn't be writing mine from scratch.

I analyzed a number of different tools, before selecting the A* Pathfinding Project. I found this project both really simple to use... and difficult to use. The primary problem I was having was that my character was stopping half way towards his destination. The sample wasn't quite right and I pulled my hair out for a few days, still unable to get it to work. 

I added in some basic movement, but my player kept hitting walls and falling over (shown below). While hilarious, it wasn't the result I was looking for. It turned out to be a physics problem. While my pathfinding is not complete, I was a good introduction and I did have some positive results (not shown below).



Friday, February 1, 2013

Shooting

With a basic level, it was time to work on shooting. First things first, I had to get rid of the soldier model I downloaded. Instead, I transitioned to a simple, blue cylinder, my player object. I then created a few red cylinders to represent my enemy objects. 

Next, it was time to actually shoot. I started with a laser, mostly because instead of having to deal with an object moving from point A to point B, I really just have to draw a line. Later I'll work on getting animated bullets and missiles to be fired. Creating the laser, with a line renderer, was refreshingly easy to setup.  

With a laser, a source and a target, I was ready to shoot! I created a little function that scanned the level looking for objects of a certain tag type ("Enemy"), and used that to dynamically create shoot buttons, to target each enemy.