AI traffic paths?

Hi

I am new to unity and new to scripting Me and my friends are creating a racing game. I am the programmer. How do i make it so that traffic car objects follow a path and everytime you restart, different cars follow that path at random? How do I create a path?

CArking1996

Hiya - welcome to Unity and the forum. That’s an ambitious start depending on your level of programming know-how. First off, I’d recommend downloading and studying the Unity sample projects to see how they are managing various aspects of a given game. I also recommend reading ALL of the Reference Manual. It is well written and there are many, many performance tips and code samples spread throughout.

I didn’t do those things (although i did have C# and JS experience), and just launched in with creating a game and snagging things here and there from different code examples. In the end, it worked, but not very well. I had fun, but did end up wasting time because I wasn’t approaching things efficiently. Just a note from my personal experience.

To answer your question directly about a path, you’d probably end up with an array of points (waypoints) and have a given car move through that array sequentially. Points in space in Unity are defined as Vector3’s (i.e., x, y, and z coordinates). There are also methods to “ease” how you might navigate between point to point so that it didn’t look like the car was on a slotted track, for example.

Search the forums and (better) Unity Answers for “waypoints” or “waypoints path” and I’m sure you’ll find plenty of examples.

Good luck with everything!

I am one of his friends, one of the creators,
http://www.helloracer.com/
Our goal is for a game like that, except for, it needs a city to drive in and traffic scripts, if anyone would like to contribute codes, models or scripts, pm one of us

If anyone can reply

thats our idea, but with better GFX and PHYSICS

Aaro, plesae don’t double post. Use the button at the top. :wink: