All Projects → mchrbn → unity-traffic-simulation

mchrbn / unity-traffic-simulation

Licence: other
A Unity asset that lets you easily simulate very simple traffic into your scene.

Programming Languages

C#
18002 projects
ShaderLab
938 projects

Projects that are alternatives of or similar to unity-traffic-simulation

Smart-Traffic-Signals-in-India-using-Deep-Reinforcement-Learning-and-Advanced-Computer-Vision
We have used Deep Reinforcement Learning and Advanced Computer Vision techniques to for the creation of Smart Traffic Signals for Indian Roads. We have created the scripts for using SUMO as our environment for deploying all our RL models.
Stars: ✭ 131 (-9.03%)
Mutual labels:  traffic-simulation
roadbuilder
Easy-to-build realistic roads in Unity. Foundation of any simcity game.
Stars: ✭ 93 (-35.42%)
Mutual labels:  traffic-simulation
DTA
This repository documents MATLAB implementation of a dynamic user equilibrium solver, including a dynamic network loading sub-routine
Stars: ✭ 55 (-61.81%)
Mutual labels:  traffic-simulation
trafficator
Traffic generator for local analytics testing
Stars: ✭ 27 (-81.25%)
Mutual labels:  traffic-simulation
docker-sumo
Containerised SUMO. Use sumo, sumo-gui and TraCI with Docker. 🐳 🚗
Stars: ✭ 49 (-65.97%)
Mutual labels:  traffic-simulation
Abstreet
Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit
Stars: ✭ 6,355 (+4313.19%)
Mutual labels:  traffic-simulation
SmartTrafficIntersection
Another AI toy project, of a traffic intersection controlled by a Reinforcement Learning AI agent to optimize traffic flow in an intersection of vehicles or pedestrians
Stars: ✭ 30 (-79.17%)
Mutual labels:  traffic-simulation
tctb
Traffic Control Test Bed
Stars: ✭ 22 (-84.72%)
Mutual labels:  traffic-simulation

Unity Traffic Simulation

intro

Traffic Simulation is a Unity asset that lets you easily simulate simple traffic into your scene.

Developed / Tested with Unity 2018.3.x and plus.

How to use

Note

  1. If you have any problem with the traffic system, press the Re-Structure Traffic System button on the Traffic System GameObject to re-generate the traffic system.
  2. Make sure to be in Top Orthographic view, in the editor, when you create your waypoint system.

Create a Traffic System

  1. Create a Traffic System via Component -> Traffic Simulation -> Create Traffic Simulation
  2. Select the Traffic System object in the hierarchy
  3. Press Ctrl + Left Click to place the first waypoint of the segment (create a new segment)
  4. If you press Shift + Left Click it will continue the segment, otherwise step 3. to create a new segment. Usually a segment stops at an intersection. Note that the vehicle will follow the waypoints depending on the order you placed them.
  5. The next step is a bit tedious at the moment. Basically you have to link the segments between each other - so when the the segment ends at an intersection, you can go to a certain number of segments which will be picked up randomly by the VehicleAI. To do so, select a segment and plug your next segments in the Next Segments parameter.
  6. To create an intersection, press Alt + Left Click and select the intersection type (stops or traffic lights).
  7. Set the dimension of the intersection's box collider so it covers all the last waypoints (cf: below image). Also make sure that the height of the box collider is high enough to collide with your vehicle.

box collider

Editing Segments / Intersections

If you delete existing segments or intersections, you will have to press the Re-Structure Traffic System button in order to rebuild the system.

Stops

  1. Select STOP as the intersection type.
  2. If you have any, select which lanes have the priority (without stop). This means if you leave it empty every lanes will include a stop and work on a first in first out basis.

Traffic Lights

  1. Select TRAFFIC_LIGHT as intersection type.
  2. Configure the two light groups by placing the segment on the group they belong to. Usually, two opposite lane share the same light group. In the example below, you would have to place the two segments ending with the blue round in one group and the two segments with the gray round on the other group.

light groups

  1. Changing the light of your 3D model can be done via your own script. An example of this is provided in the example folder.

Vehicle Configuration

  1. Setup your vehicle as follow (you can also refer to the vehicle in the example scene):

    -> Main object with Rigidbody + BoxCollider
       -> Object with vehicle's body mesh (without the wheels!)
       -> Empty object for the 4 wheels
          -> Object with WheelCollider (but no mesh)
          -> Object with WheelCollider (but no mesh)
          -> Object with WheelCollider (but no mesh)
          -> Object with WheelCollider (but no mesh)
    
  2. Select the vehicle object main parent and click on Component -> Traffic Simulation -> Setup Vehicle. This will add the needed scripts, set the proper layers and tag as well as create a raycast anchor.

  3. Place the raycast anchor in the front of the vehicle's hood.

  4. Configure WheelDrive and VehicleAI with your wanted paramters (torque, maximum speed, etc.). Set the left and right wheel mesh - they will be instantiate in runtime where your wheelcolliders are located.


MIT License

Copyright (c) 2019 Matthieu Cherubini

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].