Browsed by
Category: Police Department Game

Shadows of Doubt DevBlog #8: Simulating a City

Shadows of Doubt DevBlog #8: Simulating a City

Shadows of Doubt is a first person detective game set in a procedurally generated and fully simulated city. As head of the police detective department, it’s your job to organise your sleuths and track down AI serial killers before they strike again! Read previous dev blog entries here.

In this dev blog, I’ll discuss the challenge of creating and simulating the population of the city.

At the core of this project is the simulation of 100s of little citizens, all going about their daily routines. They all have jobs, places to be, things they like doing, and favourite places to eat and drink. Most of them will happily go about their day while you play, unaffected by the grisly murders happening elsewhere in the city. You’ll likely never interact with 90% of them. Yet they’re essential to the game because they are the hay in your needle-in-a-haystack search.

The average citizen currently makes to about 4 – 10 different journeys every day. A typical day might involve getting up and going for a coffee at the cafe down the street from their apartment before going to work. They’ll have lunch at the pizza place in the shopping mall, then back to work. After work they may visit the local sports bar before finally heading back home, picking up some groceries on the way.

Citizens’ needs for caffeine are actually simulated too!

Simulating 100s of the above would be a hugely intensive task for a system to handle in real time. That’s why I’ve chosen not to handle it in real-time. Instead, the game needs a brief period of calculation time before the start of each day (typically no more than 10 -15 seconds depending on the population count). During this time their activities for the day are chosen and mapped out for them. This way I can have the number of citizens I want without it being too demanding on the system. Of course, they can deviate from this if the situation calls for it, and their altered routine can be calculated by the game in real time as there will never be more than a handful of citizens requiring deviations. For example, if they find a dead body in their apartment they may not worry quite so much about getting to work on time!

In addition to having a routine and places to go, they also need to record what/who they’ve seen. This is in case they are relevant to one of your investigations and you decide to question them. Most ‘memories’ the citizens form are sightings- these are triggered by a global check that loops through travelling citizens and checks if they can see one another:

The green lines represent citizens seeing each other, the red ones means they have met/are familiar with each other.

Citizens can also see into windows across the street adjacent to their own if the light is on- this means in certain circumstances you may wish to question the occupants of an apartment in an adjacent building for example. It’s systems like this that can help broaden the logical options available to the player, and hopefully makes the open-ended detective work satisfying!

Citizen memories start off by being pretty much 100% accurate, but over time they become fuzzier. How long memories last depends on a large variety of factors- for example, if and how well they know the other person, their visual distinctiveness, whether they were behaving strangely, how good the citizen’s memory is in general (can be affected by age), and even the alertness level of the witness.

As memories fade, time accuracy is reduced up until the point the memory is lost completely, and therefore won’t surface when you question someone. This creates a natural time pressure within your investigation- you’re going to want to discover and question your witnesses as efficiently as possible so their memories are fresh in their mind and you can get the most accurate picture of what happened.

You may need to be wary. If the citizens know their presence at a certain place looks bad for them (they may have been near the scene of the crime and have no witnesses to back them up) they may actually choose to lie or bend the truth to avoid being treated as suspicious, even if they actually are innocent! Most innocent citizens will be more inclined to tell the truth however. Lying is whole other kettle of fish that I still need to explore in detail to find what works.

You’re not always going to need to go to searching for witnesses either. After a press release and appeal for information, you may get witnesses reaching out to you. Spending more of your resources in getting the word out about your investigation may increase the chance of this. It’s your case and it’s completely down to you how you want to handle it! Freedom in this respect is this game’s killer feature.

Shadows of Doubt DevBlog #7: There’s been a (Procedurally Generated) Murder!

Shadows of Doubt DevBlog #7: There’s been a (Procedurally Generated) Murder!

Shadows of Doubt is a first person detective simulation game set in a procedurally generated and fully simulated city. As head of the police detective department, it’s your job to organise your sleuths and track down AI serial killers before they strike again! Read previous dev blog entries here.

Last update I had made some progress on the first-person game world and these last few weeks have continued that trend. I’m enjoying working with voxels so much that switching to 3D modeling for the game actually feels like a nice break from the programming, so it’s a win-win situation as far as development is concerned! It’s why the graphics suggest the game is further ahead than it is. Since the last update, the biggest implementation is a basic character model, complete with walking animation.

Despite the endless repetition, having a human model in the game has really brought the first-person mode to life.

Originally, I had planned to make the characters as 2D billboard sprites in a 3D world (think original Doom). However, after some experimentation, I decided to try and make a character model using voxels and the same technique I’m using for, well, everything else. Turns out 3D voxel modes are actually way easier- for several reasons: The first being that it’s much less time consuming to animate compared to drawing every single frame for every animation for at least 4 different directions in 2D.  Secondly, although obviously right now the city is pretty non-diverse with my basic film noir white detective, I have big plans for having all shapes, skin tones, hair colours, and hairstyles etc. Building the character models in a way that is easily segmented into head, torso, and legs means this diversity among characters will be possible, and that’s super easy to do with voxels.

The walking animation was achieved by making different leg meshes for each’ frame’ of animation. This achieves a stop-motion-like effect. Since the legs are symmetrical, I was able to save time and resources by simply mirroring the mesh in the latter half of the walk cycle to complete the animation. I then added some subtle transform movement of the torso and head meshes using Unity’s built-in in animation editor. It’s by no means final, but honestly, it’s better than I was hoping floor (I don’t have a lot of experience in 3D animation at all, and I was dreading the task making all those billboard sprites).

These last few days saw the first implementation of doors.

But wait there’s more! This week I’ve also made some doors for the game. Doors in Shadows of Doubt will be able to be closed, open, locked, unlocked, lockpicked, destroyed and keyholes peeked-through. I’ve only got the first couple of things on that list working so far, but the implementation was relatively painless, and it all seems to be working as planned for now.

I mentioned in my last post, one of the limitations of having a procedural world is not being able to bake lighting. I’ve already come up with some culling techniques for expensive real-time shadows and illumination. One nice advantage is though, I can have dynamic lights being visible through cracks under doors- a very noir-esque way of telling if the light is on in the room within. This actually happened by accident first of all due to wonky door positioning on my part, but I’m absolutely keeping it!

Crime scenes are beginning to take shape!

Lastly, bringing this blog entry up-to-date with my current focus- crime scenes! This is one of the biggest challenges of the game as murders need to be able to occur anywhere and leave behind logical clues. In other words, I don’t just have to place some clue objects and a few blood spatter decals around- I actually have to simulate what happened and have the game generate the objects and placements using that. I have yet to really dive into the simulation aspect, I’m just getting the basics down for now.

Most importantly though, the player drops little yellow crime scene placards when you inspect a clue at a crime scene. Priorities.

Shadows of Doubt DevBlog #6: First Person Adventures

Shadows of Doubt DevBlog #6: First Person Adventures

Shadows of Doubt is a first person detective simulation game set in a procedurally generated and fully simulated city. As head of the police detective department, it’s your job to organise your sleuths and track down AI serial killers before they strike again! Read previous dev blog entries here.

This week has been hugely productive– following on from last week, I’ve implemented basic interiors so you can now go inside every building (complete with stairwells). That’s not to say interiors are anything like complete- there’s no furnishings, doors, or really anything of note, just rooms decorated in a sickly green striped wallpaper. However, the rooms even existing in 3D space is a nice milestone.

I’ve had to start thinking about the culling techniques for the game, as the game can’t possibly render every single room in every single building across the entire city at once. I’ve been able to appropriate my pathfinding/grid system to help me here, as interior space configurations are massively simplified by being on an internal 5×5 grid system, it’s able to help the engine know what to render and what to skip. The streets are rendered from inside a building, so you can see out the windows, but not vice versa. The only exception to this rule is the ground floor, which is rendered at street level, so it’s possible to have things like shop storefront windows which you can see into and out of. I’m happy with this compromise as it’s generally pretty tough to see into a window above the ground floor if you’re in the street.

I love the effect of the voxels creating such harsh shadows in the stairwells. It fits the noir theme perfectly!

After my graphical production spree, I’ve now settled back into coding the gameplay. The main reason for this is to get something at least semi-playable I can demo pretty soon. I’m finding the pieces are finally fitting together a little more. The complete simulation of detective cases gels well with the player being an active character in the world. For example; don’t want to spend several in-game hours dusting the crime scene for prints? No problem- just leave it to your other detectives while you track down a lead.

You might, want to question the prime suspect, but also canvass all of the neighbours to leave no stone unturned- again, not a problem, just leave the boring stuff to your minions! If there’s nothing for your other detectives to do, that’s not a problem either- they’ll sit back at the office and generate ‘paperwork’, which is a resource you need to unlock various orders (for example obtaining a search warrant).

Essentially it’s going to be a first-person detective game which allows the player to focus on the more interesting side of detective work. It’s also going to be possible to do the opposite and be the one sitting back at the office, passively generating the paperwork resource, while you simply order your detective teams to do everything.

I’m going to draw a line at combat though. Stealth, sneaking about and tailing suspects are definitely on the cards, but combat not so much. If I do ever decide to explore it, it would be a minor part of the game, so just to reiterate- this isn’t a shooter.

One decision I’m stuck on is what to do with the old default view; the isometric camera. As you can see below, the game looks great from this view, but sadly I cannot find much of a practical use for it. Currently, it’s been taken out- the first person camera being essential for exploring, while the top-down camera is better for navigation and a general overview of the city. You can switch between them seamlessly with the F key. What the top-down camera can’t do, however, is differentiate between different floors in a building. This could be where the isometric camera is useful.

The isometric view: Pretty but not practical for anything right now!

Lastly, with the focus now back on gameplay, I’ve been working on a first-person object interaction system. I’ve taken some inspiration from the original Deus Ex and System Shock here, as I’m sure anyone familiar with them will no doubt recognize. Maybe it’s my own nostalgia, but in my opinion, it remains the clearest graphical way to interact with the game world. Not having a first-person weapon to design around frees up both mouse buttons to become available for world interaction- I’ve not quite figured out the rules for this yet, but it gives me some freedom in that respect.

In the week ahead I’ll be continuing to evolve the gameplay. My first gameplay milestone involves having the AI killer murder someone, have the crime be reported, and then for the player to be able to visit the crime scene and find various bits of evidence.

Shadows of Doubt DevBlog #5: Pivot!

Shadows of Doubt DevBlog #5: Pivot!

Shadows of Doubt is a detective management/simulation game set in a procedurally generated and fully simulated city. As head of the police detective department, it’s your job to organise your sleuths and track down AI serial killers before they strike again! Read previous dev blog entries here.

Sometimes you can judge how hard I’m working on the game by lack of my blog updates, it’s fair to say that’s been true recently. I’m rallying to get something presentable and playable to some extent by late summer.

It’s always been my personal game dev philosophy that I’d rather make games that are too ambitious for their own good, rather than under-ambitious. This project is not an exception. Despite my enthusiasm, however, so far the ‘game’ part has always seemed off. I love a good management game, but I guess a big reason why detective games and management games haven’t crossed paths before (to my knowledge) is that… Well, it’s pretty fun for the player to do the detective work, not leave it to a team of minions!

The game needed an injection of excitement in order for me to clarify where my ideas were heading…

In the last update, I mentioned about putting a first person controller inside the 3D city that I’ve constructed, just to get a sense of what it would be like to explore the city from street level. Although my original idea for the game certainly didn’t require that, part of what makes development fun for me is trying out those ideas. It’s been a huge amount of work to create this simulated city and population, and I thought it a shame that you can’t really feel ‘among’ it with a top-down camera perspective. I only really started with the overhead perspective because it’s typically part of the management game genre. Often the reason for that is because the player is required to build things– that’s not the case here, so it seemed ripe for experimentation.

Shadows of Doubt: A first-person detective sim!

This is about the latest in the project I can comfortably change something as fundamental as this without having to remake a lot of things. The first person perspective is more of an addition than a change. I still want to keep the framework that I’ve made involving the procedural cases, population etc and even most of the management aspects. You can still pause the game at any time and interact with all the case files, as I’ve shown previously. The key difference being the player is now the detective. You’ll still need your team of professionals to complement you- (eg forensics experts, ordering DNA tests, autopsies etc). But you’ll be visiting the crime scenes, questioning and pursuing suspects yourself and generally being more a part of the world in addition to having that slightly lighter management role.

Those building lights aren’t at all random; it actually means the light has been turned on in that room (meaning likely someone is home).

This, of course, is a lot more work on my plate. As a bit of a visuals enthusiast though, I’m having a lot of fun making some of the early assets. I’ve chosen to go for a hybrid of pixel art and voxels to make the creation process relatively easy. I’m loving working with voxels- it’s like working with Lego. I have a huge catalogue of building models from Concrete Jungle which I can adapt and ‘voxelize’- it’s saving me a decent chunk of time and because the art style is so different it doesn’t feel like a cheat.

I’m pleased with the first building model in the game. Doors aren’t a thing yet though!

Because of my ‘everything-is-simulated’ approach, the procedural generation means shadow baking is unavailable to me. The lighting is going to be a bit primitive as a result, but luckily this works fine with my low-fidelity art style. It also means all the interiors have to exist in some state– when I’ve got skyscrapers with 20+ floors, this is a challenge.

This is my custom-built floor editor. As you may be able to deduce, buildings floors are planned using a 5×5 grid. I need to keep these aspects of the game as simple as possible, as the game needs to handle a lot of pathfinding to simulate the citizens. I can designate zoning to each room (for example street-facing ground floor rooms may be retail/shops, floors above may contain residential apartments). The game will populate these rooms with businesses or apartments as appropriate when the city is generated in a similar way to SimCity. The different occupant types are also contained within presets (Unity scriptable objects). I can use different floor presets to generate buildings that are different from each other internally, while keeping my workload manageable. It’s all about those nested presets! Interior decor will be a whole other layer to this, but that’s not so important right now.

I’m really excited to show more as the game progresses!