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.


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.


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.


Collision Avoidance using Raycasts in C# Code Snippet


I just add some pretty good code for collision avoidance in Space Warfare… Most code ideas I found around the nets about collision avoidance use the same block of Unity Javascript. Well, Javascript is taking a back seat in Unity pretty soon and I don’t really use it. I thought other folks might like the same code snippet in C#. Here it is!


//subtract AI thing’s position from waypoint, player, whatever it is going towards…

Vector3 target = targetYouAreFollowing.position – transform.position;

//normalize it to get direction
target = target.normalized;

//now make a new raycast hit
//and draw a line from the AI out some distance in the ‘forward direction

RaycastHit hit;

if(Physics.Raycast(transform.position, transform.forward, out hit, 800f)){

//check that its not hitting itself
//then add the normalised hit direction to your direction plus some repulsion force -in my case // 400f

if(hit.transform != transform){
Debug.DrawLine(transform.position, hit.point,;

target +=hit.normal * 400f;


//now make two more raycasts out to the left and right to make the cornering more accurate and reducing collisions more

Vector3 leftR = transform.position;
Vector3 rightR = transform.position;

leftR.x -= 2;
rightR.x +=2;

if(Physics.Raycast(leftR, transform.forward, out hit, 800f)){
if(hit.transform != transform){
Debug.DrawLine(leftR, hit.point,;
target +=hit.normal * 400f;

if(Physics.Raycast(rightR, transform.forward, out hit, 800f)){
if(hit.transform != transform){
Debug.DrawLine(rightR, hit.point,;

target +=hit.normal * 400f;


// then set the look rotation toward this new target based on the collisions

Quaternion torotation = Quaternion.LookRotation(target);

//then slerp the rotation
transform.rotation = Quaternion.Slerp(transform.rotation, torotation, Time.deltaTime * 100f);

//finally add some propulsion to move the object forward based on this rotation
//mine is a little more complicated than below but you hopefully get the idea…

transform.position += transform.forward *20f *Time.deltaTime;


Thanks to and for explaining the concept to me. If any readers are having trouble, check those sources… My numbers for distance and repulsion are based on spaceship moving at high speeds. The examples show slow moving spheres so their numbers might work better.

Next I will be adding a case where if all three raycasts hit you need to move one way or another. Otherwise, everything cancels out just about and ships still crash into stuff and explode. I kinda want that to happen a little bit so that you can feel like you are in a good asteroid chase scene, but not so much that it is over in seconds…