Unity Car & Vehicle Traffic AI Systems Performance Reviews

Technical Tech
7 min readJan 23, 2019

--

I’m comparing a few Unity Assets that help kick start a traffic system. I need it to run on 2017+ iOS devices so performance is going to be a big factor.

I’m expecting it’ll be a simple waypoint system without “proper” car controllers or navigation agents, lets see how their performance stack up.

Update: I’ve been using UnitySteer for a few days and have 25 vehicles traffic traveling along waypoints which intersect, avoiding each other with collisions and built it out to an iPhone 6 (A8 CPU1.4 GHz dual-core 64-bit ARMv8)

UnitySteer with 50 Vehicles on 2 intersecting pathways
Unity Steer Running on iPhone6 with 25 vehicles — 3ms for scripts and physics

(Pricing as of Jan 2019, everything is tested on Unity 2017.4 15f1 LTS on Mac OS X 10.13, 2.6G quad core i7 ,16G Ram, Intel HD 4000)

  1. Simple Traffic (£0 )
    https://github.com/Kink3d/SimpleTraffic
  2. Unity Steer (£0)
    https://github.com/ricardojmendez/UnitySteer
  3. Street Racing Engine 4 (€17.87)
  4. iTS Intelligent Traffic System (€67)
  5. APEX Path (Removed from Asset store)
  6. Road & Traffic System (€22.33)
  7. Driver Traffic System (€44.67)
  8. iSmart A Smart Car AI (€25.91)

Simple Traffic

“A simple traffic simulation using Unity’s Nav Mesh Components” project by Matt Dean (Kink3d) in Brighton, UK. Below you can see the demo scene running in Unity. It has some reliance on the Physx engine (orange) 3.5ms, NavMeshManager (murky green) 0.8ms and some custom c# behaviors (cyan) 0.8ms. The demo scene isn’t very well optimised though, lots of mesh colliders that could easily be swapped for box colliders, maybe around 200, swapping these should give a bit of a speed boost. There are 2 three carriage trains, 28 cars, 100 pedestrians.

Simple Traffic Performance Profiling

I’m impressed by the speed, there’s some optimisation that could go into this approach, to get a bit of an increase in performance. It’s worth noting there’s no proper “vehicle physics” like wheel colliders, just Nav Mesh agents, so the vehicles look pretty robotic in their movements not very realistic but I’d assumed using nav mesh agents would have a higher performance expense than this. I think the project proves that using NavMeshComponents and agents is a completely viable option. It’ll involve a fair bit of setup (getting all the links setup but it gets the job done using standard issue tools.

Unity Steer

This one is now 3 years since it’s been worked on (Last commit Dec 23, 2016), I had to swap out the included GoKit for an upto date one https://github.com/prime31/GoKit. This is a navigation project, more suitable for simulating flocking, performance is quite incredible though, one demo scene has hundreds of players playing tag with each other and avoiding obstacles and the impact is around 1.8ms, it has a “ticking” system to process navigation in queue, so you can tweak the queue timings to balance performance and quality.

Unity Steer Performance Profiling

Nothing in the package is traffic specific but it can handle tweening objects around waypoints and paths efficiently and has lots of modular “steer” components. You add different components depending on need, like seperate by distance, alignment, cohesion, tether to a certain area, pursuit, avoidance. The c# code is clean and commented so adding in some traffic specific components should be straightforward.

Street Racing Engine 4

This is a full “mini” city and road system. The demo scene has 100 cars, 1 ten carriage train, traffic lights and lots of junctions. Performance feels quite clunky. But it’s showing off everything which is included. Every car has 4 point lights, 2 particle effects and 2 box colliders (1 for collisions and 1 as a trigger). It uses its own simple lerp and slerp tweening for traffic movement between waypoints. There are checks on trigger enter and collisions to modify its pathways.

Street Racing Engine 4

Performance is largely taken up by physics checks on all the colliders for cars and roads 7ms, the traffic and tweening scripts are all dealt with in 1ms reasonable time. There’s a lot to optimise out of the box here though, camera effects, audio, and the UI seems to be churning unnecessarily. Some interesting ideas here, it’s all mostly thought through. The coding style is a bit simple with more overhead than is needed in a lot of scripts, again lots of simple optimisations could be made. So this could be polished into a really usable asset.

Intelligent Traffic System

This is a GTA style traffic spawning and management system.

It all comes at a big performance hit though, The demo scene has about 100 cars and 10 pedestrians. Traffic AI script 10ms, with additional calls for the car wheels and rolling behaviours is sitting at 18ms, plus about 5ms of physx calculations. Each car has a simple car controller with wheel colliders and vehicle physics. Way to heavy for my mobile requirements. The editor tools for lane editing are really nice and the setup for pathways is impressive. All the customisations seem to add to the performance weight though. The physics car controller puts this out of consideration. However if I wanted all the features and I was building for higher performance devices I think it would be pretty acceptable.

Apex Path

The Apex packages have been removed from the asset store but a lot of people consider them the best in class so I thought it would be worthwhile showing their performance in a review, the demos only have single units in them though, in the screen shot below you can see a single unit using dynamic pathfinding and the total performance impact is around 0.05ms

If you do use this package beware you’ll need to put a fair bit of effort into getting it fully functional in current Unity editions.

Road & Traffic System

A fully featured asset, waypoint style system with multi lanes, no physics vehicle controller . Using the demo scenes to measure performance the heaviest weight one with around 100 cars traveling around a complex city, multiple lanes, traffic lights uses about 8ms per frame. A simpler environment with 60 cars and 90 pedestrians was clocking in at about 6ms and a simple two lane and ten car example weighed in at about 1.8ms, finally two lane figure of eight with single set of traffic lights hit 0.8ms. So as expected complexity of environment and number of cars has a reasonable performance impact

Scripting style is pretty good, everything is fairly straitforward and there are some video tutorials to help you along. Changing out the track and vehicle models for your own ones to get a different look is a bit fiddley. Also it’s not setup to allow your own car controller scripts so you’ll need a bit of work to get that setup if you go down that route, AI cars just try and plough through “other” car controller objects. For me this is a really mature asset that does a lot and the price is great.

Driver (Traffic System)

This is a GTA styled asset, allowing you to switch between running around and driving around.

Driver (Traffic System)

The demo scene is a small city with 15 AI cars and 10 pedestrians. The scripting hits about 9ms with another 8ms for the physx parts. The AI vehicles all use physics based wheel colliders. This is a very similar system to iTS Intelligent Traffic System and performance is heaviest of all the assets tested. Worth noting that this demo only had a handful of cars compared to the iTS asset which had similar performance with ten times the number of vehicles. It’s pretty clear this system is going to be too heavy weight for my usage.

iSmart — A Smart Car AI

This is a waypoint system with a car controller that is very similar to whats in Unity Standard Assets.

Performance is okay, with 7 cars waypointing around a track, the scripts are at 0.4ms and physx 0.6ms, so performant but as far as I can tell this is 90% whats in the standard assets already. There doesn’t seem to be anything particularly “smart” about the system. Certainly not comparible to some of the other assets here. The initial demo has cars colliding with a truck and weird physics behaviours going on. I’d say one to avoid.

Conclusion

After testing out these assets for my purpose I think Road & Traffic System is the most complete system that will need the least modifications to get my project up and running, risks with it will be using a different car controller along side it. Unity Steer is a good asset if I was planning on putting some development time into building specific AI for road junctions and intersections I’d use that as a foundation.

--

--

Responses (1)