Skip to content
View in the app

A better way to browse. Learn more.

Learn more

Traffic Simulator: V0.0001

You guys know i'm fucking around with unity to make my own core for a game.. I figured I'd update you as to what I'm doing with it so far... My Turn signals are totally fucked (have to re-write the shit to be compatible with the new system) and a few bugs abound that are visually annoying but generally not a problem as gameplay goes...  Here's where I'm at with Traffic sim: startout!  I've got the pathing network created; what this network does is "simulate" traffic patterns on the roads like you normally see in the real world; it allows my minions to roam around the map on the path without a pre-set pathing.. Meaning the little fuckers go where/how they want to in order to get around, including random lane changes set to happen randomly.. which is pretty cool, it basically means you need less spawners to populate the map since they can literally come from anywhere and "join" the road traffic.  I have a few bugs in it that I don't like, easy enough to fix most of em just takes time.

For now though, I have a fully operational nav system, which includes the ability to pre-determine path options for the road segment (not the vehicle), spawners and destroyers on the map to kill vehicles and create them.  My vehicles (except buses) run on a fully "random" nav system, I have no control over where they go, they will just go till they find an end point.. Their detection arrays work fairly well (have to tweak it for side-swiping one another) when my hit one another they do not do em4 style "stop" and AI dead, instead they try to ram thru the obstruction if the detector array doesnt get em (one of ze bugs I have to fix).

The Player vehicle aside from being drivable now also has the ability to re-direct in multiple fashions, so you can turn em around, close down just the lane your in, or stop them if you don't want the traffic to move at all.  Each one triggers a different light setup, which is purely visual.  I still have to find a good way to give them dynamic lighting, right now i've got poly lighting only on them so that they don't fuck up performance.  Real-time dynamic lighting is something that makes unity go to total shit.  I have to tweak out the few minor bugs (most of em are visuals, none are "system breaking") and my vehicle nav system will be perfectly operational, it doesnt seem to consume all that much in resources so that's a good thing.  

The good thing is the very same network that makes shit happen in the rear can be used on the front, meaning you can force cars into an "alternative" lane (so long as one exists and is available to them) using pretty much the same system I already have in place.

After that I have to come up with a way for the player (me) to move around the chick to see if i can't make all the required anims for her to do her thing, she walks and sits now but i want to have her do more dynamic shit, to do that i really need control over her, not just programming it (which is what she currently does, her movement is scripted).

After I have that sorted it's onto path finding for a point-and-click interaction, so instead of driving or manually walking the person you just click on them and click elsewhere to send em there... That part scares me b/c it's going to take some serious cleverness to make it stay on the paths heading to the primary tgt (where you clicked).  I can designate "primary" and "secondary" pathing options for the thing, I just have no idea how I'm going to make it get the path it wants to take in real-time without chewing tons of resources to create that path.  This part really worries me because of how complex it will be.  I can code it, of that I have no doubt, i worry far more about whether or not the CPU load will skyrocket as a result of how it has to find it's paths... We'll see I guess

So that's essentially where I'm at with this project, imo not terrible progress but I'm trying to make my shit as "bulletproof" against crashes and major defects as well as keep the performance in check, in unity that is no small matter to do since it will let you do damn near anything you can come up with.. Only at a serious cost to performance if you push it's limits too far.  So far everything that I've intended to do, I've been able to make work in a pretty clean fashion.  Once I finish the ped/vehicle nav systems and get the chick doing her thing right I get to move onto the actual game aspect and change it from a physics/AI simulator into more of a game.. I kinda wanted to get all the "core" shit worked out before I moved into more shit since these systems are kinda critical to the "core" of the game.

Anywho, heres some pictures of what i've got going on atm.. Note: I removed most of the traffic vehicles from the spawners b/c this is a test of the network (the turn signals are still fucked up so i need to fix that before i put all the other shit back in).  So no trans ams, no minivans, no pickups, no tractor trailers, no mustangs etc. will be visible in the screens, they still exist I just have to change their systems over from the old to the new one once I get the kinks out of it.

IMO not terrible progress for a lone guy working on it in his spare time;) Once again thank you potty for helping me out with anims, without it I'd still be struggling with that bs instead of working on the shit I really need to get sorted (AI behaviors).

 

Proj01.PNG

Proj02.PNG

Proj03.PNG

Proj04.PNG

Proj05.PNG

Proj06.PNG

Proj07.PNG

Proj08.PNG

Proj09.PNG

Featured Replies

  • Author

By the by I think I came up with the system for how i'm going to make this progressive... Right now the nav system is setup for city-life, but that same system will work elsewhere and I'm going to put that to the test.. Essentially I intend to make you start off as a "rural" OEM manager dealing with emergencies in a "lakeside" mountain woodland town, a relatively small municipality.. If you manage that well your "experience" you earn (aside from budget) will permit you to move onto more county-like operations (higher density, better equipment, more challenges) growing to a relatively small city with rural outskirts to a full metropolis for the final stage you unlock.. A couple of reasons for doing this: mostly because rural=less work to setup and get the core rolling with it.. It'll probably perform better.  Plus it "unlocks" better toys as you go along so it kind of gives a goal rather than just being more or less a "sandbox".. In the end though once you unlock them in "career" mode the areas will be available for replay at any time via a "sandbox" mode where you won't advance and all the shit is pre-unlocked when you start it there... I can even throw in options to turn off vehicle restrictions and budget limits to let you play any area with whatever you've unlocked (though things from other areas would have to be off-map since there will be no way to store them on a map not intended to have em.

Multiplayer is a long ass way off as is modding abilities, because of how it works I have to come up with effective ways to permit modding, which isnt as hard for shit like reskins, but replacing models will take an insane bit of time to A. setup and B. make it available for manipulation within the game's internal system. I basically will have to replicate unity's interface to make it available in runtime, which is no easy task to say the least... Thus I'm not focused on this shit yet.  Multiplayer is probably the thing I fear the most in doing b/c quite frankly I have zero XP in setting up an MP environment;  Modding is just a fuckton of work to setup but entirely plausible to do it.  Working with the terrain map is going to be one of the hugest challenges to replicate how to setup the floor right in runtime, along with setting up vehicles since the detector arrays work the way they do I'll have to essentially come up with a way for the detectors to place themselves on a "new" instance of a vehicle... I make absolutely no promises on MP or modding functions (other than reskins) at this time b/c of how much  work that will be to actually do it.  If everyone had unity it would be a cakewalk but I don't intend on leaving the game open-sourced like it is to develop it; instead I have to find a way to allow imports so it can look for item(s) elsewhere (like a mod folder or something)... Even still though modding would in theory only be applicable to "custom" sandbox maps (the storyline campaign mode would ALWAYS require the original assets.

im sorry but i laughed at the version number. ten thousandths place lol.

  • Author

I wanted to be very very candid about that at this junction it's pretty much a traffic sim, sure the AI does respond to the redirection network, but aside from that there isnt a whole lotta game to it yet.  But the AI behavior is pretty clever, plus they seem to run glitch-free for the most part.  Most of my "bugs" are visual things so hopefully I can clear them up.  My "turning detection" array i tried to make it too light apparently so that's a bit bugged, prolly gna have to use the original and modify how it works.

Interesting read, sounds like it's going pretty well and I like the ideas you have.

I've gotten Unity to use models and assets from a file path before (set in inspector but can be put in run-time too, I was just playing around so never tried it), as far as I remember it was pretty easy to setup. Annoy thing is that I've had Unity for a number of years now and know my around it pretty well, only issue is that I've never really grasped scripting so I've never actually been able to make anything. It is something I really want to learn but just not sure where to start.

  • Author

well, depending on what you have in mind, make a topic here about it and I can probably help you "start" out.. Unity for all intents and purposes is a "blank slate"  I use 3ds for my format type b/c it's the "easiest" to tamper with, compared to the other one which is blender-spec, 3ds can come from just about any app (had that for modding in mind). Getting models and shit into unity is extremely easy, the place I have concerns is my "arrays" and lighting setups for example... You have to handle that shit IN RUNTIME (means making an editor environment in unity).  That is a big task to do.. the only way I can think of to "get around" that would be to make a hierarchy model struct and see if you can manipulate it's components separately... The way I do it is via gameobjects though so that makes it impossible to just simply import the "model' fully prepped under my system.  I'm sure it's possible but it would take tons of work.

To make a game (just a flat out game) in unity is quite easy, if you want to get into the modding/online aspects they are kind of pandora's box b/c they have to be "setup" to be compatible with your code AND have to be uniformed.. Uniformity is the paramount thing for any project in unity.  If you have XYZ that are all variables it makes A. more code and B. more places to fuck it up.

I can try to help you get "started" out but I need to know what you want to do, and in order to know that you gotta make a topic and list out your concept and intentions. From there I can try to guide you out on how i'd start the process, getting there (final method) is a ton of trial and error.  Realize this complex ass "traffic AI" system is roughly my 4th or 5th attempt at it evolving from ones that didnt work to ones that did to ones that are better.  That's kinda how it rolls in unity unless you go raf's route and just buy assets out the wazoo and repair compatibility mis-matches... Which generally is not a wise way to go.

Even from free asset store things I've tried to take a look at and pick apart to learn they either never work with your version or are incredibly hard to tie into your project. Don't have the money to waste on it anyway haha.

I do have an idea of what I want to do and it should think it's very simple to do. Only thing is that I've attempted to start it about six times only to delete it all after realizing I can't actually do it. What I've been trying to get is a simple map with roads (fictional, so no need to try and get openmaps or something else working) where incidents spawn at random at different locations and you send your units to deal with them. Then they return to their station/patrol/whatever they decide to do. No need for a shop or AI system, just the ability to send things to the incidents where they'll use the quickest route via the roads. All 2D Computer Map like (worst description ever) so only a few easy graphics and no need to worry about lighting or 3D models etc. This is something I can probably expect some people can do within a couple of hours yet it takes me that long to play around with something I've not seen before and then give up.

I understand that, AI is an extremely complex thing. The only AI stuff I've done is using Unity's NavMesh stuff with a simple script to define a "target" - 

 

  • Author

Yeah the downloaded assets (free or otherwise) are a mess because generally they don't match your ver AND don't do what your project has in mind.. The more shit you use from that background the worse the problem will get unfort.. Most things use the same function names and shit like that, so you have to change all that in order to prevent cross-compatibility issues.  I just write my own shit completely so I know it doesnt cross-compat issues.

A 2-D setup game is in theory much easier to work with for several reasons, the largest being that everything is "flat", its all texture-based on height differences not actual physical ones, so it makes navigation much much easier to figure out.. That being said though, what you want STILL requires an AI net, though if you are limiting the roads to 2 lanes (one each direction) I can help  you make a "basic" nav system that will work well enough for the purpose without having tons of overhead... It gets complicated when you start getting into the 100% random real-time shit mine does.. Don't do that on a simple 2d project.  Now onto the routing, the AI (traffic) would use a standard waypt system to ensure they stay where the hell you want them to, your vehicles however would use much the same as your little example boat project does:

How that works:

Your little "victim" is the destination tgt for the "boat", your boats soul objective is to get to the "victim" no matter what, that is actually based on code within unity, all of that "project" is purely based on the engine within unity, none of it is actually any complicated code or anything like that.  The "floor" map has areas setup on it, which permit the AI controller to navigate on it, you can set areas as walkable, walkable with a penalty, or flat out inaccessable. This is a pain in the ass to setup if you use the type of floor that I did, but if you model a "basic" floor platter with it broken into segments: IE road one model, sidewalks another, flat terrain which is accessable another, and lastly inaccessable as another it will make life easier since you can "bake" all the terrain settings separately... I'm not so great with that yet (havent gotten into it much) but that's the best method to move player objects around the map since you can make it want to go one way or another, they will behave similar to em4 vehicles in trying to go around obstructions (aka traffic) but will save tons of headache in coding all the shit i have to.

Image of baker:

As I said if you seriously want to pursue it, i can help you understand how to get there.. The c# code (one I code in) is fairly similar to c++ just diff in minor ways, you get used to it, it's very easy to code in, and most of what you "need" is already in unity in one way or another so it's easy enough to do it if you're not trying to do really complicated shit.. A "fake" 2D game with some 3D effect (basic vehicle models, basic ppl representations, and basic structures etc) would be the method i'd use so it looks similar to prison architect, which is built in much the same method, also using much the same functions as what you need (which are core unity assets).

If you need help understanding what i've written lemme know what confuses you and I'll clarify.

terrain.PNG

Made a new thread so I'm not taking up space in this one, replied there.

Guest
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.