Traffic simulator 2d

Hello,

im new in coding and i wanna build something like this: https://www.youtube.com/watch?v=232NITHBSgA

like a traffic simulator, it should be easy and 2d dont have to look good like the video, just some cars driving on a map with some intersections with traffic lights. Cars should slow down when the front car slows down or stops yeah like a normal jam. I have no idea what would be the best method for this.

Extra Question: is there also a good option to make it dynamic so the maps is easy changeable? like a drawer for everything?

Edit: https://www.youtube.com/watch?v=mu7f3Z1lRsE&list=PLcRSafycjWFdDou6OTCmGbRZ9lwLXjuMO
this would be exactly what i need with the road builder(without the houses and pedestrians, i just need automatic traffic lights at intersections)
but unfortunately the code is just outdated cant make it run
thank you

You need to break it down into smaller steps:

  • you need to make the maps… b/c you mention 2D and dynamic maybe you would like Tilemaps and Tiles?
  • you need pathfinding for pedestrians and for vehicles, and a constraint is that vehicles need to be strongly biased toward the right side of the road. Pathfinding is a bit heavy for a newbie so I would recommend using one of the popular assets from the asset store.
  • you need to modify the maps to have physics triggers, such as on cross walks, that cars can detect and slow themselves down, then this information needs to affect the pathfinding
  • you need the cars, which raycast in front of themselves to detect if they’re approaching obstacles. They use the pathfinding system to figure out how to get from point A to point B.

The place to start is the map and that should help you clarify the next steps.

Not sure where you got that idea but I assure you simulators are not at all easy.

I suggest you start with some games like Flappy Birds or Roll-A-Ball first, get the feel for the lay of the land.

Or, if you insist on starting with a traffic simulator, as Lo-renzo says, you absolutely MUST break it into tiny digestible steps, the same way you eat a meal: one bite at a time, not by lifting the entire plate and pouring it into your mouth.

Check out how this guy does it:

Imphenzia: How Did I Learn To Make Games:

Two steps to tutorials and / or example code:

  1. do them perfectly, to the letter (zero typos, including punctuation and capitalization)
  2. stop and understand each step to understand what is going on.

If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.