- Home /
How to make computer controlled cars?
I'm making a racing game and I need to make opponent cars which move around the track by itself. They need to move around the track automatically, and react to crashes. Their speed will be steady normally, but will increase/decrease if another car crashes into it.
I'm scripting in JS, and It'll really help if sb explains what to do as I'm new.
If you're new, you probably don't want to start with coding a racing AI which even reacts to crashes! :) But tell us more about your problem.
How is your track defined? Do you mark it with some hidden lines or checkpoints, or you just put objects to the scene? A lot will depend on how you do this, but I never did navigation in Unity so others should come up with some actual answer.
Without this knowledge, I would create points along the track which would be navigation points, and the opponent cars would follow these points one after the other, smooth damping their rotation towards those points as they go.
http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$athf.SmoothDamp.html
This is a very simple solution but you should begin with this if you're new.
Answer by vagos21 · Jan 09, 2013 at 01:25 PM
this is quite a large subject that's been in development for 30 years in games :) if you wish to make your own racing AI you could search on google for "racing game AI" and start reading... :) or you can use for a very small price a library like this:
http://arges-systems.com/blog/2009/07/08/unitysteer-steering-components-for-unity/
good luck!
Your answer
![](https://koobas.hobune.stream/wayback/20220613090640im_/https://answers.unity.com/themes/thub/images/avi.jpg)