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.

Embers of Empire Update – AI Dynamic Navmesh / A Star Experiments

screen_12.08077

Ever since this summer I’ve been struggle to make my AI better. I have Behavior Trees in and really easy to debug logic now, but the path finding has become an issue. The AI stumbled across the age old robotics problem of escaping a concave obstacle. I added a big derelict alien space craft that is integral to the story and a super cool set piece to fight around and explore, but the AI acts like an idiot ramming itself into the structure with the current avoidance AI. The current avoidance works ok for smaller obstacles but when things go on for miles in one direction, path finding seems to be necessary. So, off to AI school I go again.

I looked into the new dynamic navmesh for Unity and its ability to be created on surfaces that don’t necessarily have to be horizontal. I thought I came up with a good hack, but it still doesn’t always work, and the dynamic building of individual navmeshes for lots of ships is going to be a problem when battles scale up. In the video below the agent doesn’t change its angle much, even tho I programmed it to do it and it was doing it a week ago… A great demonstration of how hacky and unreliable it is. It was an exciting idea tho, especially given all the off the shelf stuff you can use with the navmesh like steering and formations. Too bad..

Since I don’t really like how the navmesh system fails a lot and building the navmesh over and over is necessary and slow because you need to keep orienting the plane in different directions so the ship can move in 3D, I decided to start looking into other stuff. 3D A* was an obvious place to go, but A* is not super fast-especially in 3D over great distances. So, I am looking at a Jump Point A* where you can have a mesh of nodes, but you don’t have to traverse symetrical nodes and you can jump to ones where you need to make a decision. I am thinking of it as like a line of site type thing. If you don’t have a direct shot to the target, traverse through nav nodes that connect to create a clear path.

Currently I am working on ways of generating efficient node maps of my levels. I am thinking of using non-uniform cubes represented by a bounds object at runtime. When baking the navmesh info, the cube might start very big like 1km in volume and if it detects a collider within it, it will break into small cubes that test for colliders until you have some areas with finer navmesh data. This way the empty areas of the map would have fewer navnodes to traverse, but when a ship gets in close to an object they need to path find around the nav data will be more refined. This of course sounds great on paper, but I need to make sure I can generate such a thing without locking up Unity or making the player wait an hour for the next scene to load. If it works I think I can add some very cinematic dog fights and ship battles with the small craft dodging and weaving in and out of complex space stations or between capital ships.

Space Warfare: Infinite April Developer Log

April has been a busy month!  I’ve been putting in a lot of hours bringing the game back to demo level with the new graphics and the new code spurred on by some good pressure due to awesome interview with Fists of Heaven and a video chat with  ThatCooperFellow. In retrospect, the whole year has been rather busy if I think back on it…. here are some things I’ve been up to…

Lasers, missiles, explosions!

Lasers, missiles, explosions!

Since last year, I’ve:

  • rewritten a lot of the ship components – making the engines and maneuvering more realistic and customizable to work on all different ships,
  • made more complex AI with goal setting and steering,
  • implemented some moving origin capabilities to make the battlefields more expansive and allow for some seamless travel – still WIP,
  • created the beginnings of a procedural galaxy generator that builds different galaxies and nebula and plots planet locations as well as assigning star types, planet types-based on distance from the star etc- and other details,screen_7.920277
  • created some new nebula types that can be randomized and colorized for more variation
  • created and found some procedural substance textures for planets that work with Unity5 lighting and can be randomized for variation through the galaxy generator
  • built a few new HDR space skyboxes
  • made new cap ship models that should lend themselves to part swapping to make more type variations (more to come),
  • new beam weapons and missiles,
  • more complex turret AI that takes orders from its main ship AI to focus fire, target certain types or even fire at any targets of opportunity,
  • more complex explosions that have multiple stages for bigger ships (still wip but already looking pretty cool)
  • implemented a new radar and target tracking system connected it to the AI
  • targeting now seamless allows for targeting whole ships or component pieces
  • targeting all based on factions and classes instead of unity tags – more complex relationships and more advanced decision making for AI
  • there is a new mission / battle editor that I worked on over the summer too – something I need to start revisiting soon.screen_46.13708

Here is a recent video of some of the dogfighting action (hoping to get a cap ship video up soon too!)

AI Attacks GIF

I’ve been doing a lot of work on the AI this week. They are getting smart! I’ve got an FSM that uses steering behaviors now linking to a Goal processing AI so that each AI can determine goals and the steps to carry them out (or follow orders from other AI who commanded them!) Here is a gif of the AI attacking! No real complex thinking in that one tho!

 

View post on imgur.com

Developer Log – Building my own galaxy

All week – during my snow days! – I have been working on procedurally generating the galaxy for Space Warfare – Infinite. I have been researching a lot on the old Elite as well as my Traveler RPG core rule book to help inspire me through it. I’m also using some complicated math to generate the galaxy shape. Essentially the galaxy generates and determines what sort of stars are Red, White, Yellow or Blue as well as their sizes. Then it determines how many planets they have. When you investigate an individual star system, the game runs some code to figure out what planets are their and what their characteristics are.

screen_16.33853

Here I’ve got the stars being generate and each star is a star system with a number of generated planets. The big grid sphere is my work on picking areas for various factions to control so in the one pick there is a blue faction and a yellow faction. The control spreads just out of the sphere to directly linked systems. The control zone is within a certain radius of the home star. Faction areas will name their systems with their own naming conventions – either different influences for human factions or alien languages for those factions. Also from here I can catalog the resources from each planet and determine the strength of the factions to give them bases and fleets etc. Taking over a new system would mean adding to that strength later in the game. 

screen_54.12553On the top left you can see my simple read out of planet info for the selected star. It’s not super formatted for the players yet. I just wanted to get the info out so I could see what was happening. screen_67.16019

I still have to work on nebula regions and adding more detail to the star systems like asteroid fields and things. Once those are in, the galaxy generator will be hooked up to the actual game engine and generate the star system the player is in on the fly. Then players will be able to FTL jump to other systems as well. Below is a shot of the Galaxy map projected on the UI so the player can pick a place to jump to.

screen_67.58907

New Let’s Play Video – Space Warfare: Infinite Plays Angels Fall First

I’ve decided to do a series of Youtube Let’s Plays of games that I enjoy playing that I also draw inspiration from. I plan to show off some of the game’s features and discuss the things I am working on in Space Warfare: Infinite. So, first up is a game I’ve been playing a lot of – Angels Fall First. This game has been in development for awhile, and I’ve always been inspired by their Space, Air, and Ground combat. They cover both space sim combat and first person shooter combat. You feel like you are in a big war every time you play. I love the feel of the game when you touch down in a warzone and I think the ship models and locations are pretty cool. I definitely look to some of their fighter models for inspiration. I also love being able to run around inside the big ships.

Angels Fall First came out on Steam Early Access Oct 1. You can grab it here: http://store.steampowered.com/app/367270/

They also have a website at http://www.affuniverse.com/

Developer Log #2 – Creating a Mission Editor for Space Warfare: Infinite

I’ve been hacking away at a less fun and visually unimpressive part of the game idea for Space Warfare: Infinite — the Editor. The mission editor will hopefully be one thing to help set the game apart. As a gamer, the one thing I’ve always loved is being able to create my own game maps and play them. I made my own text adventures, had 3D Studio, I made stuff with the DEU – Doom Editing Utility, tried my hand making Unreal Tournament levels, made my own Starcraft maps. My hope is that this will be a feature that will attract an audience. I call it a Mission Editor, but the scope is going to be more than that. When its complete the player or me (I plan on using this to build the entire campaign mode of the game….) will be able to create simple battles, missions with objectives that range from patrol and fight pirates to a scripted battle between two giant fleets complete with dialogue and cutscenes.

Screen Shot 2015-07-07 at 9.15.31 PM

Features I am currently coding:

  • Place ships, stations and other objects on a 3D map.
  • Select a setting including naming the sector, adding planets, nebula/other background art, asteroids. Setting space dust/nebular clouds.
  • Place nav points and waypoints.
  • Trigger and Event Scripting – Trigger events like spawning new ships, winning a mission when ships are destroyed / navpoints reached, displaying a comm message etc.
  • Mission set up – Briefings, objectives, Debriefing, Success / Failure
  • Camera control for cinematic cut scenes
  • Campaign Editor – Connect missions together into a full game sequence – with ability to connect missions based on success / failure or other triggers

Currently, I have the XML backend working pretty well. You can move around the 3D map, place and manipulate ships. I have mission set up in and saving to a file. I have extendable menus for objects to place on the map as well as extendable lists of events and triggers. I am in the process of solidifying the events and triggers stuff and getting it to save to the XML. After that I am gonna jump back into the engine and make sure it plays nice and decodes some sample missions. I also have a mock up of the setting editor…

Planned / Stretch Features:

  • Ship yard editor – Customize, edit existing ships or other objects. Change default load-outs etc. Build new ships from component parts and add them to the game for user-created campaigns. (Customizing ship data will be available in xml no matter what… ). Something like this will be useful for my own dev so I might make something like this part of the initial tool set. At least to set up different specialized ships so I don’t have to dig through XML files.
    Unity is tough to mod for. I am looking at way to import user generated models for ships etc, but at the moment the moment it’s looking complicated. I have some ideas, but I can’t focus on it just now. On the flip side, modeling component based ships is already happening so adding a build-your-own based on my already modeled ship pieces might be simpler. I might even add some Star Trek / Star Wars -inspired hull styles etc, so that players can design their own styles.
  • System Map Editor – Like the campaign editor but missions would stand in as maps, they would be connected by triggers like reaching a nav point in a warp to bring you to the connected map.

 

Developer Log #1- Modeling The Fleet in Space Warfare: Infinite

Over the last few weeks I’ve been trying to limit my programming time to focus on 3D modeling. I find switching between Unity and Blender to be difficult, so just working on making stuff in Blender has helped my productivity in creating new art assets for the game.

Sketching and modeling in Blender.

Sketching and modeling in Blender.

I have a list of space ships that need to be made and I’ve been working through it. I am almost ‘done’ one faction’s main ships. I still need to model a new fighter–and I might do a 3D cockpit while I am at it. Keep in mind nothing is really done. Everything is WIP. I’ve haven’t quite gotten my skills yet for painting textures and generating bump maps so there is still more work to be done. Also, as time goes on, these early models might need to be redone if I get better.

A new battlecruiser - 1 kilometer of destruction.

A new battlecruiser – 1 kilometer of destruction.

Above is the battlecruiser. Its basically the battleship class of the space fleet. For some reason I can’t use battleship. The ISC ships are going to be more boxy like current military ships and tanks. The other faction will have more sloped / angular plates on their ships.

screen_64.67316

Huge carrier ship capable of launching fighters and corvettes from those two bays in the front.

This is the carrier ship. It will have some point defense turrets on it, but other than that it will rely on its fleet and fighter squadrons to defend it. The carrier is also big enough to launch corvettes which will be used as anti-fighter type ships.

screen_67.37792

The corvette. A ‘small’ ship.

The corvette is the latest model I’ve made. Its meant to take on small missions and has weapons geared more towards fighter management or hit and runs on capital ships. The ship is fast but would probably get eaten up if it tried to go head to head with ships of the line.

The Destroyer-class. This ship is 500m long. Its got around 8 turrets mean for engaging other cap ships and point defense. It has a deck mounted rail gun and an  internal beam weapon.

The Destroyer-class. This ship is 500m long. Its got around 8 turrets mean for engaging other cap ships and point defense. It has a deck mounted rail gun and an internal beam weapon.

The Destroyer will be the workhorse of the fleet. The cruiser is a force to be reckoned with but these destroyers will pack a punch. A couple destroyers can take out a cruiser pretty fast.

Very early space station.

Very early space station.

After these, I plan to remake the fighter and then start on the enemy faction. I also have dreadnoughts on my list as well. They’d probably be 2km. Additionally, I started messing with Space Stations.

Here is a video where I talk about the ships and compare their sizes…

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.

Dev Log: Space Warfare: Infinite – New Game Modes, Gameplay Video for Capital Ship Battle and Patrol

This last week I’ve been polishing up the current build and sending it out to some testers to try it out. Also, on Tuesday I will be on the Space Game Junkie Podcast at about 10PM EST. Check it out! I’ve been a fan of the show and have really used them as a resource for inspiration and ideas.

screen_231.5574

Some of the major additions have been getting the Battle Editor up and running and adding an Instant Action mode which currently house some missions as well as a place to load player created battles. The game will also eventually include Dynamic Campaigns with a story line of the unfolding war as well as branching mission paths depending on the completion/failure of objectives.

screen_165.9012

After that I’m going to work on a Free Play mode where the player can visit the many star systems of the game to trade, take missions, fight and explore. I am hoping to figure out a way for the Battle Editor to add content to all three game modes – Players should be able to build their own campaigns and scripted missions, as well as make Instant Action battles and build missions / locations for the Free Play mode.

Screen Shot 2015-03-15 at 9.25.52 PM

I recorded a video of playing the Capital Ship battle in Instant Action as well as a patrol mission.

Beyond the menu system, the battle editor saving and loading systems, and a lot of testing, I also added some other features. juskelis – maker of Starfire – offered to do a little alpha testing and had me make some tweaks to the roll of the ship as well offer the ability to invert the mouse. I also added warning messages for when power is low, armor is critical and when you take hull damage. I think it helps give the player some awareness about how much trouble they are in. Someday the console in the cockpit will spark etc.

screen_200.2657

Another thing I tweaked – the player can now swap through all the ships in their fleet and control them. Before it was designated ones, but after all the refactoring, the switching ships works for anything now. It could also work for turrets, but I disabled that for now as I don’t have a control interface for turrets yet-they are run by AI. I want to add more control eventually since it’ll be more fun to have it when flying the cap ships.

As for next steps, I guess I’d like to hear what Space Game Junkies think I should add and just keep plugging away. The power management system is still just a fraction complete – I want to add reactor components to ships and hook up the energy draws to them to balance ships. Then I want to create a custom load out screen so the player can select their weaponry. Particularly for the Instant missions as well as to be used on some campaign missions. After that, I really want to add a Frigate, Corvette and Battleship to the ship list. I have some ideas for some sick battles. I want to work in formations for all ship types as well. Currently ships don’t play nice when you have them form up. So I want to work on that. Oh and add more AI stuff since thats not complete yet either – maneuvers are their, but currently enemies just pick from them randomly. I want them to make some interesting choices.