You may remember that last week I made a spaceship model. I think I could do better if I were to have another go at it, but this model is good enough for now:

I didn’t mention it last time, but this isn’t a single ship model. Instead it’s built from modular pieces, and those pieces only cover the starboard side of the ship. I can then flip the pieces around if I want to put them on the port side. This means I can make the ship asymmetrical if I like. Also, I could make it arbitrarily longer by copying sections.
Before we scrub this model and start over, I want to see it in motion. Now, if I was building physical models, then I could hold this thing in my hand and run around the room while making spaceship noises.

But since this model is just data, we’re going to have to settle for animating it on the computer. I could use Blender for this, but I’m more comfortable with Unity. So let’s import my model there.
First I have to create a new Unity project:

Let’s talk about these options:
- 2D – I don’t make 2D games, so I never use this.
- 3D – This is the default I use for most unity projects. If you’ve ever looked at a game and thought, “This looks like it was made with Unity”, then it was probably built using this template. The lighting model is designed to be mostly idiot-proof, which has the downside of looking a bit bland.
- 3D With Extras – Same as above, but with some example assets to show new users how things work.
- High Definition RP – This is the fancy-pants Unity setup for projects that want to use cutting-edge rendering techniques and are going for a more AAA look.
- Universal Render Pipeline – This template sets the graphics to work almost anywhere, including mobiles and ancient PCs. Good if you’re doing mobile development. Bad if you’re picky about visuals.
I usually go for #2, but what the heck? Let’s shove this model into the fancy-pants HDRP and see what it looks like…

Oh hey. Bloom lighting? That’s cool. I guess that’s enabled by default here. In my projects I normally have to jump through a bunch of hoops to add bloom.
This looks cool, but I’d like to see it in a proper space setting. Let me take two minutes and whip up a cheap space-backdrop…
(Almost an hour passes.)
Wow. The HDRPHigh Definition Render Pipeline. The “fancy pants” graphics. looks better, but it’s also almost an order of magnitude more complex to set up. The various lighting systems are all interlinked: Ambient light, atmospheric scattering, reflections, post-processing / color grading, global directional light, and background image. This is probably really handy when you’re trying to set up a terrestrial scene, but it’s a huge pain in the ass when you want to turn off half of these features. Like, it took me twenty minutes to find the settings to get it to stop drawing a horizon.
Anyway, once I have the settings wrangled I toss a 3D skybox over the scene.

Okay, there’s still some sort of horizon being drawn. I have no idea why or how. There are a dozen different dialog boxes that control this stuff, and they all have a dozen or so settings, and I’m pretty sure I’ve tried everything.
This was supposed to be the mega-easy part, so it’s mildly infuriating that I can’t get it to render this very simple thing the way I want. I feel like this entire sky / fog / ambient / sky system is way more spread out than it needs to be. There are a couple of dialogs that don’t seem to do anything, and from reading the docs I get the sense that I’m seeing some middle-point between the “old way” and some yet-incomplete “new way” of setting up your scene in the HDRP.
Whatever. I just wanted some stars behind my spaceship for the next step. I’m content to live with this goofy space-horizon for now.
I want some smaller ships around. I jump back to Blender and model something that might generously be called a flying triangle. It looks like it was drawn by a child, but I don’t really care. I just want some small fighters to fly around and I don’t plan on looking at them up close.
I whip up some code for a fighter. Now, this ship would just be a speck moving around the scene and that probably wouldn’t be very interesting. But I remember that way back in early aughts, the game Homeworld helped you visualize the motion of all the ships by having them leave glowing trails.
As luck would have it, Unity has a built-in “Trail Renderer”. I just attach it to the back of my fighter and tell it how long (in seconds) I want the trail to be. That’s it. Unity does everything else. If the ship moves faster, the trail will naturally get longer.
I add a handful of these ships to the scene and let them swoop around randomly.

That’s pretty fun!
This is giving the ship the sense of scale I was hoping for. The ship feels more like a carrier now, and less like a space bus.
So… since I made these fighters. Why not make them fight?
I add the concept of “teams”, and I make two squads of fighters: Red Team and Blue Team.
Now, in any of my pre-Unity projects, making dogfighting AI would have been a massive pain in the ass. Not difficult per se, just long and tedious. There’s a ton of code you need for moving and “thinking” in 3D space.
But with Unity, all of that work is already done. Pages and pages of code can be expressed in one or two lines. For example…
transform.forward = Vector3.Lerp (transform.forward, ai_desired_heading, 0.02f); transform.position += transform.forward * speed; |
Every single object in Unity has a “transform”. This structure keeps track of the object’s local orientation: The “forward” value always contains the vector of where the fighter’s nose is pointing, regardless of the fighter’s position in space. It also has an “up” vector, which would point out of the cockpit. It would be “up” according to the pilot, ignoring what’s going on outside. The transform also keeps track of where the object is and some other key facts about its behavior in the world.
All of that work is done for me. All of those numbers are already calculated and ready for me to use when I need them, so I don’t have to write code for tracking that stuff myself.
The first line of the code above takes two vectors: The way I’m pointingtransform.forward, and the direction the nose of the fighter would be pointing if I was aiming directly at my enemy.ai_desired_heading It then calculates a vector between these values. The final value – 0.02 – tells it how far between these values to go.
This line boils down to: “Turn 2% of the way towards my target.”
Two percent doesn’t sound like much, but keep in mind that this is done per frame. It’s going to do this at least 30 times per second, which can result in some pretty sharp turns. A value like ten percent will result in ships doing near-instant turns, which looks not awesome.
Now, if I was trying to make a game, then I’d want something a little more sensible and balanced. Maybe I’d put an upper limit on how many degrees you can turn per second or whatever. But I just want the fighters to put on a show, so I don’t mind if they make lots of wide looping turns.
The second line of code just shoves the ship forward according to its current speed.
In my old C++ projects, this would be pages of code. But here in Unity land, I’m doing all of this complicated movement stuff with just 2 lines.
I give the fighters the ability to fire lasers at each other. The result:

Now, at this point in the project I decide to take a break. So I alt-tab over to YouTube and randomly stumble on the announcement for Homeworld 3.
The series has been dormant for years. I’m doing a project that roughly copies the superficial look of Homeworld, and suddenly I hear that a sequel is coming.
I realize it’s a small, inconsequential coincidence. But it was still quite a shock for me in the moment.
I should do a project to recreate the look of Half-Life and see if anything happens.
EDIT: As requested, here’s an animated GIF of the action…

Footnotes:
[1] High Definition Render Pipeline. The “fancy pants” graphics.
[2] transform.forward
[3] ai_desired_heading
Tenpenny Tower

Bethesda felt the need to jam a morality system into Fallout 3, and they blew it. Good and evil make no sense and the moral compass points sideways.
Self-Balancing Gameplay

There's a wonderful way to balance difficulty in RPGs, and designers try to prevent it. For some reason.
The Best of 2014

My picks for what was important, awesome, or worth talking about in 2014.
Stolen Pixels

A screencap comic that poked fun at videogames and the industry. The comic has ended, but there's plenty of archives for you to binge on.
Silver Sable Sucks

This version of Silver Sable is poorly designed, horribly written, and placed in the game for all the wrong reasons.
The best “story” you can give to an object is to just put it somewhere that would make it look really out of place. This can be utilized on both sides of the spectrum, it could be really funny or really scary but people are probably going to be compelled by and ask questions about it either way.
“Hey, Shamus, why are those ships orbiting a giant speedo?”
X-Wings defending the Y-Fronts.
I dig it.
It’s a bit of a shame you didn’t record a video clip of your swoopy shooty triangles in space doing their thing. That still screenshot just doesn’t convey the sense of motion and action you’ve talked about having added.
Honestly, I kinda like the look and the idea of that space horizon.
Wouldn’t work for most realistic games, of course, but if you’re going for that ‘ships & subs among the stars cruising along on a luminous ether sea’ type sci-fi, I could see some real fun scenarios in how you manipulate that nebula above you as the game maker.
Space storms whipping the nebula as it was clouds. ‘Rains’ of minor space debris making your shields light up. Maybe even the clouds parting, showing some mega-structure behind it…
Again, not exactly realistic by any means, but think it could be really cool visually if done right.
Invaders From The Dark Side of the Universe
There’s a pretty straight forward way to make a “space horizon” realistic. The Milky Way as we see it in in the night sky on Earth is basically the galactic plane seen edge-on from the inside. From our terrestrial view this looks like a diagonal arc across the sky, but from the POV of an interstellar space ship it can be any orientation, including a pseudo-horizon. Pretty much any flat-ish galaxy type will have a feature like this when seen from the inside, so it doesn’t matter even if your setting is some space fantasy in a galaxy far, far away.
The further away your destination is (on the galactic scale), the closer to the level of the galactic plane your ship is going to be pointing, so depending on your story and how efficient your FTL is, you can make an argument that your ships might spend a lot of transit time oriented within, I dunno, 20 degrees of the galactic plane.
Visually you can probably make some hay from your shot blocking relative to the plane/”horizon”. Like, you can give the scene an emotional bias depending on whether your ship is “descending” or “ascending”. Since in space “up” and “down” are purely relative to the camera frame, you don’t even have to worry about whether the destination is actually “north” or “south” of the plane, save for continuity purposes.
“Clouds” or “storms” in open space aren’t a thing, and nebula are misused for this, as they are HUGE and diffuse, so only visible as “clouds” from lightyears away. BUT dense accretion disks (maybe) and gas giant upper atmospheres (definitely) can provide exactly the visuals you’re looking for there. Both of which are huge enough that being in them would actually look and feel like being in a cloud or storm in space.
You could have really terrifying hazards like passing through an interstellar gamma ray jet you had no way of knowing was there until you were inside it. This wouldn’t be visible in the sky outside the ship, but hooo, boy, would it “light up” the ship itself (and any “energy shields” it might be using). This would be the closest to a Star Trek “ion storm” IRL, but it would be a light-speed phenomenon, so mappable to a FTL civilization, rather than a nautical-style randomly moving/occurring “storm”.
A “rain” of small debris is absolutely a thing that could happen. In interstellar or interplanetary space extremely rare, but still plausible. In planetary orbit it’d have to be the fallout from something recent (like within a decade or two), but otherwise even easier to justify. The main thing would be to treat it like something highly special/unusual, rather than just “oh, another storm”.
It’s funny that getting ships to chase each other is incredibly simple, but “make space not have a horizon” is incredibly hard.
Obligatory XKCD 1425 in website link. In CS, it can be hard to explain the difference between the easy and the virtually impossible.
It’s even more amusing here because both these tasks are easy/hard for the same reason of already being done for you.
Can we name the starship… “Jeff”?
I would love to see a gif of the fighters battling around the ship.
Yeah. Good call. I’ve added one to the post.
It’s not the most brilliant camera work. (The camera is pretty barebones right now.) But it should get the idea across.
Awesome. I love how straightforward the animation seems to have been.
It looks great, I was expecting the ships to get tangled up with each other at some point I wasn’t expecting those swooping runs
Shamus says “I decided to try Virtual Reality, only lasted 30 minutes, it was horrible”
Valve releases Half Life: Alyx.
They are waiting for you, Gordon. In the Test chamber.
(Seriously though: I think something like Homeworld in virtual reality would kick serious ass).
Funnily enough, if you look for “Unity horizon” in Google, “Unity remove horizon” is one of the first autofill results, so clearly you’re not the first one with that issue.
You’ve probably already googled this and solved it by this point, but I’m curious, was this the solution?
https://answers.unity.com/questions/921088/unity-5-removing-horizon-in-the-background.html
That post is from 2015, so I don’t even know if things in Unity are the same these days.
Don’t make 2D games, huh? I see.
I feel like we’re about to enter a rabbit hole that will take a fair while to find our ways out of.
Man, looking at that GIF I can almost hear the old Homeworld radio chatter. What a game, such sound design, such visual design… come to think of it, I do own it on GOG, don’t I…
I’ll take this chance to ask yet again whatever happened to Pseudoku, because I don’t think Shamus ever replied.
I believe Pseudoku was programmed before Shamus started doing serious game dev in Unity. As a result, it was built with his own homebrew code and has persistent portability problems. There were also some parallel business bureaucracy hassles he was struggling with. The combination defeated his willpower, and the project continues to languish in obscurity along with the “spaceship interior” code project and the re-tooled city generator.
Your accounting re: My growing list of failures is flawless.
So, I tend to think like this as well, with various projects I’ve started and never finished being labeled failures in my mind, but I read a book last year (I think it was “Range: why generalists triumph in a specialized world” by David Epstein) that got me thinking about it a bit differently.
Essentially, one of his points was that great artists aren’t great because they never turn out out junk, but because they produce a lot in general, giving them more chances to make great stuff; if something doesn’t work out, they simply move on to the next project. Shakespeare penned the real clunker Timon of Athens between King Lear and Macbeth, but he didn’t let its failure get him down; he just started a new project. More pertinently, perhaps, Michelangelo apparently left three-fourths of the statues he started unfinished. If a project wasn’t working out the way he wanted, he had no qualms in dropping it and starting something new, and remember him for the finished statues rather than all the unfinished ones.
The takeaways were that no one puts out perfect work all the time, even the people we put on a pedestal (but also that the experience gained from sub-par work can still be valuable). I know it sounds cliché to think of them as learning opportunities rather than failures, but it really helped me re-contextualize things I’ve done in the past that weren’t as good as I wanted or which I abandoned. It’s obviously more difficult when those things affect other people (probably why I tend to be reluctant to discuss projects I’m doing until they’re actually done, in case I decide to abandon them), but for what little it’s worth, you have this stranger on the internet’s vote of confidence that they’re not failures. (Or at least, they’re only failures if you let them be? Something like that.)
Read Atomic Habits recently, and the photography class story really stuck out.
…this may or may not be a tangent.
Then there’s the saying, oft quoted to Europa Universalis IV players trying to choose between the military idea groups of “Quantity” (more soldiers) and “Quality” (better soldiers), that “quantity has a quality all its own.”
(Definitely a tangent.)
It’s a wonder Da Vinci ever got paid he finished so few projects.
IIRC part of the motivation was also that there didn’t seem to be any sudoku games at the time? But I’ve seen plenty flash by on Steam now, so the moment may have passed.
Shamus: “I feel like just quickly modelling a spaceship in Blender.”
Later Shamus: “So, I’ve got this cool demo of animated space-battles with AI fighters and lasers and…”
Seriously, that’s pretty cool. I quick like that last screenshot (and the GIF looks great too).
I’m wondering if a barrel roll animation would make instant turns look correct. One of the really cartoony ones, with colorful roll lines.
This relevant reddit post yesterday is about a little Unity spaceship sim.
Sigh. My comment was eaten by the spam filter again. Not even put into moderation queue. It hates me.
A minor Unity quibble: the turn speed and movement rate should be multiplied by Time.deltaTime (the time between frames) so that changes in framerate don’t cause changes in fighter motion.
Shamus doesn’t even need to touch the code, if he just says the fighters have a frame shift drive.
I audibly gasped when I first saw the ship with the bloom lighting. It looks so cool! As does the dogfight. It really nails that Homeworld look.
Please, please, please do! It’s high time those guys learned how to count to 3…
Yes, finally! Another programming/art series!
I love these so much, and I’ve been waiting all this time for you to start another one of these. Thank you!
And you’re awesome.
Well there is Project 17, which looks pretty great!
Sure hope nothing happens to that kid!
“Two percent doesn’t sound like much, but keep in mind that this is done per frame. It’s going to do this at least 30 times per second, which can result in some pretty sharp turns. A value like ten percent will result in ships doing near-instant turns, which looks not awesome.”
I thought it was a big no-no to tie stuff to the framerate. Since you end up with still like https://www.youtube.com/watch?v=ZFVtXjr-Nno.
It is indeed a no-no. Like I said in the article, I would have done something like “degrees per second” turning if I was trying to do it right. But this was close enough for the half-assed airshow I wanted to create.
Alternately, as long as this code is running in the Update method or something else called once a frame, you can just alter the amount the ships move and turn (and/or any other per-frame translation) by Time.DeltaTime! It can be awkward and poorly planned in places, but Unity really is a lifesaver for these little conveniences.
I really enjoy this kind of content – programming, explaining complex IDE type objects (I’ll probably never try Unity – I’m a back end natural language processing type guy – but it is fun to see someone else struggle with it). Looking at the GIF I’m sad there wasn’t a paragraph or two about how the lasers were added: was that hard? Does Unity have an “Add laser” button? I feel like it might. I also think that each ship must track some sort of hit points value, because I saw one of them get hit (oh to have a discussion about hit boxes, and how to determine if a laser is inside one or not – I remember two decades ago trying to code up hit detection code and there are lots of optimizations in that area) and then flame out and explode. Lots of complexity hiding behind that I suspect!
Super cool.
Unity has built-in collision testing, so my guess would be either the ships have simple collision volumes that trigger code on being hit by a laser (an object with the laser model/sprite), or the entire concept of hits/misses is a setup and it’s predetermined that most shots will miss, but every once in a while a laser is fired accurately into another ship, destroying it. That has the advantage of not requiring physics calculations for potentially hundreds of fighters and thousands of lasers, and nobody could really tell the difference so long as this is all the fighters do.
Wait – now I’m interested to know how it works!
I think my favorite examples of space ships with a mix of greebles and color is scifi cover art by Chris Foss. He often did colored strips along the hulls of his ships, or even section of striped or checkered patterns that are very distinctive. Something about the paint jobs make the ships and machines feel very human-built to me.
Oh yeah, the stuff he did for Jodorowsky’s Dune is simply amazing! As is the rest of his work, really.