Newbie adapting Race Demo to include AI - help needed?

Hello to the unified … total Newbie with little to no coding history …
I’ve just begun the learning curve … and having done the tutorial FPS, car tutorial and studied a few example scripts … I thought a good learning project would be to adapt the Race Demo to include AI players to race against … but where do I start??
I tried using scripts from the car tutorial but they don’t seem to be appropriate for the Race Demo …

I’d like to keep the acceleration / rpm / kph functions adapted to include a randomly generated input … which is all seemingly OK although I could probably do a better job of it when I really know what I’m doing (as opposed to just floundering as I am at present) …
but where I totally come unstuck is in getting the AI to steer accurately and cleanly … the attempts I’ve had thus far have had extreme behavioral results … I’m not sure if the steering method coupled with the WayPoint method used in the Car Tut is relevant but that’s what Ive been attempting to integrate into the car script in the Race Demo.

Totally flummoxed … Please Help!

also what is a simple method to return a result to the screen … so I can see where the maths is going astray? …

thanks in advance!

Hi
Welcome
Theres car AI programming in the racing tutorial -you should have a go with merging that? Ask away with questions…
Welcome welcome welcome…
AC

Did you mean the Complete Car Tutorial?

is there a simple method to return a result to the screen? … so I can see where the maths is going wrong

…yes…

…no…
Try posting problems in small steps. Basically you want to get the two projects merged into one,(I would anyway) Make a prefab out of the waypoints and Ai cars, and drop it into the Glossier race demo…move stuff round and hit play…

Then go model some nice autos’
AC

sure there is. you can send values to the console with

Debug.Log (“myVariable”);

you can also send things like position, rotation, vector3.blah, myNextTarget…

a more complex way would be to send it to a temporary guitext but the console is easier.

Thanks for that … yeah I just read about out how to do the Debug.Log when I was thumbing through the complete car tutorial … and that was a great help in diagnosing where the problem was actually coming from … basically the original code output a result that was too extreme for the Racing Cars … the car tut cars are cute … but a little bit slow and clumsy for the racing track … wheras the racing cars are hurtling along … so suddenly turning 30 degrees has a definite impact … also the method for turning the wheel was different as the code for the racing car originated for use by a human “Player” … but I liked the rpm - kph code that it was using … so I’ve adapted the AI code to comply with the code.

Looked like it was gonna go my way when I fell unconscious last night … so I’ll have a go at tweaking it today at some point … couple of things like the default start pos for the AI etc … cause at the moment it has the same default as the “Player” which means if you have a crash involving both cars they try to reset to the same place at the same time which creates another crash … usually more dynamic than the first crash …

thanks …

Finally sussed out what the main issue was … the waypoints were positioned incorrectly … I didn’t take into account the banked corners of the race track … so the AI car was not triggering the waypoint selection script as it wasn’t driving through the waypoints around the corners … thus no new co-ordinates were being generated for it to aim for … the script seems to do the trick now … more or less … although it definitely needs modifying … for the ai to be smarter … it’s a little bit clumsy and although the script works the ai tends to crash into the barrier from time to time … also I need to set up a start off acceleration script so the ai has a more natural acceleration … I’ve attached a copy of the script I used for the AI-car … it’s probably a bit clumsy but hey I am a newbie to this stuff … any tips or feedback would be appreciated …

cheers

44844–1632–$car_ai_116.js (7.79 KB)