Line of Sight

Hey Folks. Bit of a diversion today, as I'm somewhat ill. Not quite sick enough to throw in the towel, but enough that I allowed myself to pursue an idea brought on by a fever dream last night.

One problem in the space prototype that I've been putting off is the question of how I'll render lights, line of sight, and user perspective. It's a ball of factors that are interrelated, and so far, I haven't found a good solution.

Up until recently, I assumed I could just use Unity's lighting system to handle both normal-mapped sprites and shadow-casting. It works, and actually looks really good when it runs. But it turns into a real pig as soon as there are many sprites and/or lights visible. Basically, any ship of about the size I want every ship to be.

So, I turned off shadow-casting, and that was that. (Performance was acceptable in exchange for a less-cool art style.)

Last night, before bed, I started tinkering with some lighting solutions. And later on, while sleeping, my mind kept wandering back to the problem. (Instead of sleeping, much to my chagrin.) I wondered if I might be able to limit the rendered geometry and lighting to what the crew can currently see, and if that might allow me to reenable the shadows on the lights. In theory, if we're only seeing a room or three at a time, instead of the whole ship (and docked ships/stations), maybe that would be sufficient?

So I put aside the heat stuff and gave it a shot. Today's image is the result of a day's work.

It certainly could be better, but that's actually not bad. And apart from some tile-walking code and some dimmer/hiding code on my items, the only other change I needed to make was to inflate my tile collision meshes from 2D quads to 3D boxes for line-of-sight raycasting. It has some pros and cons, so let's enumerate:


  1. Shadows - We get shadows again, which are nice to look at.
  2. More Lights - We also can manage more lights per ship, since fewer are running at any given time.
  3. More Dynamic - The scene is a bit more interesting to look at now that we have rooms visible vs. not, and some peeking views into others.
  4. More Tension - We can't see everything, and that's good for creating tension. E.g. "What was that bump?" "What's behind that door on this derelict?"
  5. Free Combat LoS - Whenever I get around to combat, I can reuse this code for line of sight/cover/etc.
  6. Exploration - Related to tension above, we have a reason to walk around: exploring the environment.


  1. Costly - This line-of-sight calculation is expensive to run, and needs to be updated whenever the viewer moves to a new tile, or an item changes modes (like a door).
  2. Errors - We still have some edge cases which produce visual errors, like wall corners and limited doorway peek-through.
  3. Multiple Crew - What do we do for multiple crew? Do we show all at once? Or just the currently-selected?
  4. Fog of War - How do we show areas that have never been seen vs. areas we simply cannot see right now?

And, of course, the big question remains. Are we just the captain? Or can we see with any crew member's eyes?

Overall, I think there's something useful here. The gameplay benefits alone (tension, combat, exploration) are pretty big, and there are a few ways to go about this which might solve one or more of the problems.

Tomorrow, assuming I'm better and not worse, I'll probably resume with the heater code. I may tinker with this more, as well, or perhaps I'll move on to more tools and derelict explorations. Whatever I choose, I have to admit it feels good to be surrounded in interesting problems again. Problems that each seem like they'll enhance actual gameplay/feel, and aren't just invisible plumbing.

Tags: Ostranauts


Rovlad's picture

>Are we just the captain? Or can we see with any crew member's eyes?

Considering that we have character creation, and you've implemented line of sight, it would probably make more sense if it was the former. Maybe seeing the whole ship at once could be some kind of a perk, or even a surveillance system upgrade for the ship then.

Would also give players incentive on keeping their own character alive, maybe even at expense of others. Which is potentially even better for more in-crew relationship drama.

PS. Hope you get well soon!

dcfedor's picture

Thanks! Almost there, I think. I feel almost normal except for a bit of congestion.

I think you're right that the captain is the best place to start. My main concern in that case would be ensuring the crew is actually useful instead of a time sink. That, and to make sure their antics aren't wasted out of LoS :)

Dan Fedor - Founder, Blue Bottle Games

Rovlad's picture

It could work out for the best, more mystery and interesting quirks coming into play instead of log spam of "[x] stares longely at the old photo" and "[x] furiously doing push-ups". Even though he's in EVA suit in outer space.

dcfedor's picture

Part of the original design spec was to make that log spam a bit less spammy, and a bit more entertaining. Something one wouldn't mind watching during long flights across the system. But I might have to admit that's beyond my capabilities, and it'll end up just being boring.

But the cool thing about developing a game like this (slowly, via testing) is that it's possible to pivot design choices if they turn out ineffective. Terrible for project management, but cheap to maintain, and as long as I don't lose sanity/intelligence from being alone for so long, hopefully a better product :)

Dan Fedor - Founder, Blue Bottle Games

Rovlad's picture

I'm not seeing much testing going on. :)

dcfedor's picture

You got me :)

It feels kinda like a rock and a hard place right now. On one hand, the biggest risk is lack of gameplay. Everything else in the game is meaningless if it isn't fun.

But on the other hand, there have to be systems (and related content) in place for that gameplay to interact with.

There was a point a week or two ago where it felt really close. Like I could just fly over to a derelict and loot stuff, then return with it to a vendor and sell it to buy supplies (or keep the loot for my own ship). The looting tools and EVA suit were directly supporting that.

But there wasn't really any risk involved in doing so. Except maybe running out of O2 or fuel on a longer voyage. So it was more going through the motions, and occasionally getting excited about unique loot to ogle for a bit.

The heating/cooling stuff adds a bit more survival gameplay, as now we have to manage three things: food, temperature, and air. It also gives us a bit more potential loot (heaters, coolers, or potentially parts for them).

Which all kinda feels like it's moving in the right direction, like NS's survival elements and the tools to mitigate them.

But yeah, I do occasionally wonder if I'm drifting from the path into the weeds again.

Dan Fedor - Founder, Blue Bottle Games