Sandbox Crime Game Tutorials or Thoughts?

I got to thinking about criminal simulation games, like GTA and Saints Row, (and indie games Rustler and Shakedown Hawaii, which I grabbed recently) and I am wondering if anyone knows about good tutorials for how to make them. I'm actually having trouble even thinking of what to search for. GTA-clone tutorial? Sandbox game tutorial? Criminal Simulation game tutorial? I'm not even sure what the proper terminology is. I know there probably aren't any for Godot specifically, so if anyone knows of a tutorial for that kind of game aimed at Unity or general programming, I'd be interested to take a look at it.

It also seems to me like a crim-sim is mainly a collection of small pieces all working together. Traffic sim, crowd sim, aggro behavior, police appearing, etc, these are all relatively simple things on their own, it'd just be a matter of making everything react with one another and feel organic. If you know of any good tutorials or tricks for these individual components, I'd be interested to hear that too.

It also seems like the main thing you'd absolutely have to have for a crim-sim is a strong grasp of optimization, which I've always had trouble with, since I come to game development from the artist side of things. That's another topic where I don't even know what keywords I should be looking up.

So if you know of any tutorials or helpful tricks or just want to speculate and discuss the genre, I'd be happy to hear from ya.


  • cyberealitycybereality Posts: 3,792Moderator

    I doubt you'll find a tutorial for a full GTA game, it is probably too advanced for something like that. I know there are some for Unity (even full games you can buy on the asset store) but I tried this and I found the code to be too confusing to follow.

    In any case, it's just a combination of different elements you can find tutorials for. Like 3rd person character controls. Using AI and navigation path finding. Car physics. And so on. So I would start by breaking down the elements into specific features and just figuring that out by itself. The third person character controller would be a good place to start. Then maybe make one car and have it controlled by the player (and learn how to make an animation for the player to get in a car). Then code NPC AI via path finding or steering behavior. And so on.

  • TwistedTwiglegTwistedTwigleg Posts: 5,251Admin
    edited November 2021

    I think breaking it down into smaller elements and learning how to create each of those in a semi-modular way, so that you can combine them and build additional elements, is probably the way to go.

    I think it also depends on the direction you want to take with the game as well.
    For example, if you want to have large crowds and groups of people, then you'll likely want to look into crowd simulation techniques using particles or other forms of instancing so you can render many more skeletons than you could otherwise with just instancing alone. I have not worked on any games that use this myself, but I believe this is how zombie games handle having so many zombies on screen at once. I think you can also bake the animations into vertex colors or something like that, but again, I haven't really explored the topic myself.
    However, if you don't need large crowds and groups all at once, then instancing normal Skeleton nodes/meshes and pooling resources might be sufficient. You could just remove people when the player gets far enough away and instance new ones as the player goes to new areas, making it seem like there are lots of people but in reality there is only ever a small amount at any individual time. I think this is how GTA does it, which is why if you see an NPC, leave for awhile, and then come back, the NPC is gone or replaced with another NPC.

    I agree with @cybereality that breaking it down into smaller parts and tackling it one at a time is the way to go. I would start with the fundamentals that the player will be interacting the most with first (player controller, game play mechanics, etc) and then branch out from there.

    Edit: As far as optimizing goes, I wouldn't worry too much about it initially, I would just try to make the elements semi-modular. Then if/when performance starts to become an issue, it should be easier to tackle because all of the elements of the game are not so tightly interlinked that a small change could have a cascading effect (or at least, that's the hope!).

  • I'm not really enough of a computer science person that "modular design" means anything too me. I kind of understand the meaning of the words in context, but there's nothing specific that jumps into my when I read them.

    I'd rather think about optimization early because I've had several games that crashed and burned halfway into the project because some optimization problem happened and I had no idea what to even search for. (this was back in AS3 Flash, not Godot) I'd rather start with at least a vague idea of what scope I'm capable of. Hence, any general optimization advice would be appreciated.

    And I have tried to look up Godot Optimization before, and I felt like most of the answers were, "nobody knows". I'm just hoping someone has looked into more deeply by now.

    And I'm very comfortable with my current 3D top-down-shooter engine, so I've got all that basic stuff already figured out.

  • cyberealitycybereality Posts: 3,792Moderator

    Mostly because I don't think anyone has attempted to make a GTA-scale game in Godot so far. I believe it's possible, but there are probably many small issues you will encounter, but you won't know until you encounter them. So it's best to just start working on it and deal with them as they come up.

  • well, I don't actually want to make something GTA-scale. I've been enjoying indie GTA-likes Rustler, Hawaii Shakedown and Streets of Rogue (which is debatably something else) and wondering how close I could get. And I'm more a fan of Saints Row and Sly Cooper anyways, which I feel like are indie-doable than some of the GTAs are.

  • TwistedTwiglegTwistedTwigleg Posts: 5,251Admin

    @AcetheSuperVillain said:
    I'm not really enough of a computer science person that "modular design" means anything too me. I kind of understand the meaning of the words in context, but there's nothing specific that jumps into my when I read them.

    What I was trying to say is making each component/part of it where it doesn't rely on other aspects in order to run, so if you need to change/remove a part of the game/level/etc, it doesn't cause a cascading chain of everything breaking. That way, you can add new features, swap things out, and adjust code without having strange bugs pop up or have a total game crash if something seemingly unrelated is adjusted.

    For example, if you make the system that for diving cars modular in the player, then if you need to remove the ability to drive cars (for example, maybe the maps in the game are too small for vehicles) then it doesn't cause any breaking issue. Or, another example with the driving system would be if there is a bug in driving, you could fix it without needing to worry (at least as much) that something in the climbing system (for example) is going to suddenly break because of a fix in the driving, since the climbing system doesn't rely on anything in the driving system.

    The general ideas is to make it where it's not super interlinked so each part can be worked on, fixed, and swapped around as needed! It's one of those concepts that is easier said than done, but especially for games with lots of moving parts and complex interactions, I imagine it would be helpful.

    (Though I haven't made a game like that myself, so it's mostly speculation on my part :smile: )

    I'd rather think about optimization early because I've had several games that crashed and burned halfway into the project because some optimization problem happened and I had no idea what to even search for. (this was back in AS3 Flash, not Godot) I'd rather start with at least a vague idea of what scope I'm capable of. Hence, any general optimization advice would be appreciated.

    That's fair, I've had that issue a few times. Again, since I haven't done it myself I cannot speak from experience and instead have to speculate, but what I imagine are going to be big bottlenecks are NPCs, making the world load in/out as needed to save memory and performance, and making all the complex systems work together.

    For NPCs, one of the first things I think will need some optimization is path finding and collision, since most sandbox-crime games require NPCs to react to their environment, run away from enemies (or towards the player if they are attacking), and otherwise just act like they are 'living' in the world. I imagine a lot of tricks are used for NPCs to make it seem move lively and populated than it really is, like deleting NPCs when out of sight, making path finding only work nearby the player, and other tricks. I'm not sure on the specifics though. There might be some GDC talks on this type of thing, though I did some quick Google searches and didn't find anything.

    For making the world load in and out, there's a few ways I can see of doing it: Chunk-based loading/deleting or streaming the data. Chunk-based would be where the world is broken into smaller sections and then you just delete ones that are too far from the player and load new ones as the player moves in. I know that games like Morrowind use a system like this and it allows for a big world, though in Morrowind the technology of the time wasn't quite there for loading/destroying at seamlessly.
    This article seems to implement something similar in Unity.

    For streaming levels in and out, I think that is how GTA does it. This is completely speculation but I imagine how it works is that it loads a low resolution version of the map (maybe in chunks?) that contains a very low resolution and low polycount version of the scene. It doesn't include any entities, NPCs, or really any game play elements, just a basic visual. Then, as the player gets close, it loads a higher detailed version of the scene just in that spot, populates/spawns the entities, and activates game play elements. Spots further away are replaced with the low-resolution version again until the player reaches them.
    That is how I think it is done or could be done, but I'm not positive and haven't looked into it really. I know that some game engines have systems build in for level streaming, so it may be that there's other, better ways of handling it, but that is what I might look into doing as a level-streaming like solution.

    Finally, for the complex systems I'm not really sure what to recommend. Like with NPCs, I imagine a lot of the optimizations are saving processing time by only processing what would be interactive or visible to the player, and letting things that are too far or invisible just freeze until they are needed again.

  • some good stuff, thank you.

    With NPCs, I know my game can spawn a dozen or so badguys at once doing occasional pathfinding without any noticeable change in performance.

    I saw one tutorial suggest that you keep NPCs attached to nodes until they get "turned on" in combat.

    Like so^
    As long as you design your nodes without obstacles between them, they shouldn't even need collision detection.

    And this is essentially how Godot's pathfinding works anyways, I think. I know in my game, the pathfinding finds a node path and then my NPCs go to the next node in a series of straight lines, updating their path to the player every couple of seconds. An NPC that isn't following a moving target, like a citizen just going from their house to the supermarket or whatever, could get away with only consulting the pathfinding once.

    I could also imagine a less object oriented approach to NPC AI, like a big singleton moving things around instead of them acting independently. For example, let's say you're walking down a crowded street and shoot someone, you want all the NPCs to react. So instead of each NPC object constantly running some check to see if something happened, your singleton notices the gunshot and/or KO and says something like
    for a in NPClist:
    if NPClist[a].distance_to(event) < reaction_distance:

    So as long as you keep your active NPCs down to a dozen or so and your less important NPCs are basically particles, I think you'd be able to do a lot before you reached your bottleneck. It'd certainly be more of a bottleneck for player skill to be fighting a dozen baddies at once.

    Chunking environments is a mysterious and frightening realm for me. A friend of mine was doing some experiments with that and they always seemed to run at a snail's pace. I've got Penny de Byl's Udemy course on making a Minecraft game in Unity that I've been meaning to try and do in Godot now that I'm more familiar with Godot, but I haven't made time for that yet.

Sign In or Register to comment.