Working on a 3D A* algorithm for Embers of Empire

It’s been a bit of gap since my last post and that’s not for want of doing gamedev! I’ve been working on completing a Web Developer program over the last 6 months so I generally have not had much head space to work in Unity and C#. I have become a better programmer, however, and hope that I can apply some of the things I’ve learned to my gamedev sideprojects.

(Sorry if I am talking too quietly on video – everyone was asleep in my house!)

Recently I been working on Data Structures and Sorting Algorithms and it made me think back to my pathfinding problems I was working on last fall. Getting a better understanding of algorithms made me want to tackle A* and see if I could create a version adapted to a 3D space game without grinding the framerate to a halt. If I can get it to  work, I can get my AI to navigate the giant Ember ships during dogfights much more convincingly. One challenge is the A* complexity increases as you add a 3rd dimension since you go from testing 8 neighbor nodes per pass to testing 26! Not to mention the vast playing field makes the grid huge!

A couple things I am doing- AI ships will still do some Raycasting to see if they just have a clear shot to their target. If they get too close to an obstacle and its in the way they ask the A* pathfinder to find a path.

I plan to add a way to check if the path brings the ship to an open shot to the target early thus they can abandon the path. Also I could figure out a test that determines if a pathfinding can end at an early node because that node has line of sight. This will cut down on lots of searches when an AI is just jumping around one asteroid. I also want to add a way to cancel a path if the target moves into the open, etc.

Additionally, I may tap Unity’s job system to let a new thread handle the pathfinding to keep the program from stuttering as it calculates. I figure paths could be generated async with far enough lead time that the ship wont crash.

Dev Log: Bigger System Maps, New Procedural Generation Work

screen_121.3082I’ve spent most of my time lately reworking the way the game builds the galaxy, solar systems and local regions where the combat takes place. Just about got floating origin working so that the game can support battles over a solar system without having to jump between points of interest in separate zones. Also worked it out so planets and other big objects can be approached and not be background. Space stations or entire fleets could be on the other side of a big object and the system will handle switching everything from 3d skybox to real stuff to interact with. Also I am messing around with some art like this space station mock up. Its not a final piece, just something I through together to see wh
at it looks like in game.

Space Warfare: Infinite on the Space Game Junkie Podcast!

screen_140.1852

At the beginning of the week I was lucky enough to be on the Space Game Junkie Podcast! The hosts of the podcast have a website devoted to all types of new and old space video games. (Space Warfare: Infinite even has its own wiki page on their site!) If you are looking for a new game to play, they have 99 episodes covering all sorts of games as well as video reviews of games. Its a big source of information and inspiration for me, so it was great to be on the show and chat with hosts about making space games.

Here is the link to the Space Game Junkie Podcast featuring Space Warfare: Infinite…  (for the younger audience of this blog – some of the hosts on the podcast let a few curse words slip so perhaps make sure that it’s ok with your parents to listen if you are still living with your parents… )

screen_322.5109

All in all, the podcast was a lot of fun! I still think my voice sounds weird and I need to work on my elevator pitch about the game, but it was totally cool to see some people who really love space games play the game I am making. I also got some good feedback for things to fix like FPS controls confuse people when the shift key changes the controls…. the A/D key might be a slide instead of roll or at least I should add a slide/strafe feature since folks are expecting it after Elite, the targeting needs to be fixed because its confusing and not super responsive (I’ve already fixed the targeting subcomponents issues)–I need to add arrow indicators or make the offscreen target box larger and brighter so folks can track the closest target. I’ve got a few movies and games to check out as well.

Space Warfare: Infinite – New Gameplay Videos with shields, new weapons, explosions!

Sadly, I die far too fast to show a lot off in these videos but if you look closely you will see the capital ship’s shields and two of its turrets blowing up any incoming missiles. I’ve also added some of the new weapon features to the UI so you can see what guns are selected and watch me flip between them. There is also ammo values now which will probably make a lone fighter long for a carrier to go back to reload on–it’s coming!

 

I’ve been working on setting up base classes for ships and weapons which is sorta why there are lots of new projectiles and guns to choose from. I also worked on making the cap ship blow up in a cool way and might use the explosion scripts for all the explosions. I sort of simulated delayed subsequent explosions. I need to make the ship come apart next instead of just disappear tho… I’ve got a list of about 48 todos still to work on before… before I make another list…

Dev Log for Space Warfare: Infinite – Beam Weapons are awesome

Still working on capital ship weaponry and it’s fun! I’m actually doing a lot of clean up under the hood since my general programming process is get something working that I can play with on the screen as fast as possible and worry about making the code better later. I am in a make the code better phase because capital ships are far more involved than fighters and they are forcing me to break out some of the systems I just hard coded into my fighter scripts so that after I am done, I’ll be able to iterate more ships, turrets, weapons, other objects faster.

dontmesswbeams

Capital ship with one beam weapon lays waste to a fighter wing…

BEAM WEAPONS!

One example of this current decoupling is beam weapons – a totally different style of ‘projectile’ that still works with the components I built. The main turret I made last weekend just fires off regular cannon projectiles which are the same things that the fighters shoot. It’s been my standard projectile along with missiles for a long time. Standard cannon projectiles do 1 damage to the hull (armor and shields haven’t been implemented yet…) and missiles do a bunch more. The beam weapons are set to 1000. They cut through anything and can destroy multiple ships in one hit. I’ll probably dial it back but its fun to watch the thing just vaporize fighters like gnats. I envision this level strength weapon to be a capital ship attack weapon so the turret will probably track slower and generally just target other big ships. I might also make a short range faster tracking anti-fighter beam to punish players who get to close. The beam weapon definitely makes a cap ship something to fear.

On the technical side – I used a line renderer with a collider for the beam and I hacked together a lense flare and light at the origin of the beam. I might add another lense flare type thing to places it hits stuff so that it looks like a weld torch. Might be a cool effect that is different from the regular sparks and stuff of other weapon collisions.

Space Warfare: Infinite – Screenshots gallery galore

Here are some of the latest screenshots of Space Warfare: Infinite! Still WIP and still in pre-alpha, but it’s also still a lot of fun!

Developer Log: Space Warfare: Infinite – Capital Ships and Turrets

I spent the weekend putting together a capital ship and its turrets. Its still a work in progress, but it is fun to have to play around with.

screen_20.71244

Capital Ship!
I built the capital ship model using Pro Builder. I’m still a true amatuer at modelling, but I am working on it. The ship is a carrier-type with a big fighter bay on the side. It’s about a kilometer in length, but you can only really tell if you put a 3rd person character on it and walked around. It seems like the trick is to put bunches of detail panels and sloped surfaces on it so it doesn’t look like a flying cube. I am using games

like Freespace 2 as a reference since the ships were boxy but people still liked them. Once I get some nice models together, I will explore real texturing. The current carrier isn’t going to be in the finished game – at least not the model in its current form. The main goal was to get something giant to fly around and fight against that had a killer amount of turrets. Ta -da !

screen_50.51213

Having the cap ship, tho, gives me lots of directions to go. It’s be cool to have the player fly out of a fighter bay tunnel at the start of a battle. I have an idea for smaller gun boats that would be a much smaller cap ship with a big gun and a pd. They’s have less armor, but would be a bit more maneuverable than big stuff. They’d be used in groups to attack big

ger Battleships by attacking from different angles and things to overwhelm defenses. Going one-on-one with a battleship would be a big problem since a big gun might take it out in one hit, but a group could score a bunch of hits while a big gun can only focus fire on one target.

I want to get AI together that will allow the cap ship to maneuver. Once that happens, a second capital ship so that they can fight each other. The current one would have to have AI that would make it find an average waypoint in the middle of the action so it can get in there and mix it up with fighters. Or, it will need AI that can chart a course along the side of another cap to do a flyby. If all caps follow the current gun load out a dive and attack would be a good strategy since a caps guns are on top mostly, so getting under the enemy will offer a passing attack while not getting exposed to the bigger guns on top.

Also there will be at least one cap ship with a giant trench in the middle leading to some sort of highly explosive power core. It will be the only cap ship that a fighter might be able to take out on their own.

Turrets!
The turrets rotate and look up and down to target enemies. Currently they are sort of Point Defense guns, but I am also going to add anti-capital ship guns, beam weapons and missiles. The model for the turret is really for a big anti-cap gun.

screen_112.2582

My basic thoughts are that all guns on a cap ship should be on a turret since the ship can maneuver as simply as a fighter. Big anti-cap ship guns will rotate slowest, but pack a big punch. Currently, if a fighter is unlucky enough to get hit by a anti-cap projectile its instant explosion.  Big guns will prioritize other big ships that aren’t zipping around. Point Defense (PD) guns will track and take out fighters and missiles that get too close. Currently each turret has its own targeting AI. I hope to also add a targeting list function for some guns like PD and high-fire rate missile launchers so that they can move briskly between many targets. In a combat mission against Capital Ships, the main goal of fighters is to take out the PDs and other guns to make way for missiles to take out the ship. I am thinking some classes of cap ship will have strong enough armor that standard cannons on fighters won’t do any damage at all.

Dev Log: Space Warfare Infinite – Using Unity 4.6 UI for the HUD

 

The Unity 4.6 UI is really quite easy to use and it does not really on OnGui calls! I am adding some Data screens for the ship, just not sure what to put in there! Targeting info and ship status seem like the obvious choices. I like that you can make it look 3D so it feels like they are projected on the screen.

screen_70.66354

 

I like the immersiveness of cockpits, but I don’t like how they obscure your view of the action. I want players to be able to see the game and see what they are doing. I stared at the Privateer cockpit for a long time but that doesn’t mean it was the best way to see the game… I think I like the Elite method because its so open, but I like Star Citizen’s info panel design.

Key Features:

  • Better crosshair
  • Radar
  • Targeting
  • Ship / Shield Status
  • Systems Status
  • Enemy Target Info
  • Ammo / Fuel Status
  • Distance to waypoint

Inspiration screenshots:

Elite-hud

Elite’s HUD

 

starcitizenhud

Star Citizen HUD

privhud

Privateer HUD -not enough view!

Dev Log: Space Warfare Infinite – New AI tricks, missiles for everyone! and Unity3D Bloom findings

screen_78.26921Over the past week I’ve been having a lot of fun with Space Wars, while also researching and reading about AI. (I also got a little sidetracked by trying to perfect the bloom image effect….)

AI

AI can make a game like Space Warfare pretty exciting. I plan on having some multiplayer aspects once I get the major systems together, but the focus of the game is really a single player experience at this point. Since that is the case, cool AI pilots who behave in interesting manners is important. My actual AI code at this point needs to be refactored because it is a big mess, but the things its doing already even without a really nice organized OO state machine are pretty fun. I plan in the future to build out more of a Playmaker-esque state machine for these guys but it’ll take some focus. Because of the behaviors of the AI, the game is becoming pretty fun to watch. It has the enemies turn and loop and barrel roll to escape or ambush each other.

Current states include Chase, Attack, Reposition / Flee. Within those states the ships are able to barrel roll in reaction to being hit as well as change target focus. My idea is that I want to have some base states like Attack and then have a bunch of maneuvers that can be employed by the pilots depending on their style/personality/status. I am looking into multiple temporary short range ‘waypoints’ to create maneuvers so that AI can do looks or spiral at another ship instead of go in a straight line.

Some of my research to me to the above really cool video from Star Citizen (disclaimer: I am one man, Star Citizen will always be cooler than my game…). It hints how they are thinking about AI and displays some quick shots of the Ai engine. I can’t afford to hire that Ai company but I like some of their approaches. One of the things they really focus on is collision avoidance which made me think – oh man I don’t have anything to collide with yet other than really small ships better get to work on that! Unity’s Nav Mesh seems out because its a 2D plane and not a big open space. I’m heading towards a raycasting set up for individual ships. I forsee it being a little costly so I might have to add some collision radius objects that trigger the raycast steering only when necessary. One video that seems to explain the basics is here: http://vimeo.com/9304844. Sadly the author seems to have disappeared from the internet and never continued the series.

Missiles

I’ve also implemented missiles into the game. They are basically have perfect tracting to the only way to not get hit is to accelerate long enough that they can’t catch up or have them hit or get hit by something. I am working on a few countermeasures like a ‘chaff’ like drop and perhaps flares. I know chaff is for radar, but I might make it a dual purpose item in this game. It just drops a bunch of chunks of metal behind the ship that can clog an enemy radar with blips or set off a guided missile if a chunk collides with it. The other balancing option I will add is the length of time the guidance system works. This will give the player the ability to outrun then dodge a missile over a range if the guidance cuts out early, but is still a threat if the ship remains on the same course.

When I have add the ability to upgrade, ships could by better missiles with longer range guidance systems to make them harder to shake. As it stands now, unless your opponent launches a missile from too far away, the likely outcome is an explosion. Its so likely that for the above video I needed to disable missiles just to show you the Ai fighting without immediately creaming each other with missiles. Also I wouldn’t be able to stay in one place and film for my that 10 seconds before getting hit myself.

Missiles are a powerful weapon. But I always feel they are underpowered in games. Perhaps I should make it a little more random – 10% chance of surviving a missile? Perhaps its time to add shields!? Also individual parts of ships might mean less instant kills if its not a direct hit.

Bloom

On the Bloom front… well the game is shiny now! Look at the before and after!

 

screen_306.4306

Before…

screen_11.3738

After…

Things I’ve learned so far… some Unity image effects may be added after every camera is rendered. This means that no matter what camera you add an effect to, everything is gonna get the effect. The bloom happened on all my cameras no matter what my order was or culling set ups were. I’ve tried it all…. If someone out there reads this and finds out a way to make my findings untrue, I would love to see the solution! Comment, twitter, email me!

The main problem I’ve had is that the really nice Space for Unity scenes were getting over exposed and washed out so that you couldn’t enjoy the scenery. Since the main thing I wanted blooming were the trails and lasers, I ended up really brightening the particle materials they were using and then turning up the ‘threshold’ setting on bloom so that everything doesn’t wash out. It sort of works. I like more glowing than less so I am happy where I am with the look. Sometimes I feel like almost Bloom alone makes the Unity Pro license worth it — just the cool factor.