- Home /
How do I add bots in android?
Im making a racing game for android, and im trying to add more cars that will be your opponents. If anyone could give me the script for it, or explain to me how it is done, I would be willing to pay a $40 reward, if i can get it to work.
Thanks!
Answer by Meltdown · Mar 30, 2011 at 03:13 PM
I'd suggest taking a look at this tutorial
Paying special attention to Step 5 where AI is explained. Although for your benefit I'd suggest doing the tutorial from scratch.
Within the downloadable project is the complete AI script which uses waypoints to make the AI cars go around the tracks.
With regard to offering money for work/solutions, the correct place to post that is in the Unity Forums under the Commerce section.
Answer by Justin Warner · Mar 30, 2011 at 03:16 PM
Lol, money might make some people post =P.
For racing...
Have nodes on the map... These nodes are just path ways. And each set have their own tag... so like, set 1 set 2, 3, 4, etc...
So, you have the racer start at 0, (Start...), then you have a script....
If the time is 0 (Go time... going to assume it'll be like, 3-2-1 GO), if time is 0, find new target, each racer finds next tag... so the tag would be followed as... "i", so, you i++, get the next tag, it adds all those tags (Use a for:each), so, it adds those in to the array (You can use a List), so now, it random number's, and grabs that number of the array/List, and it goes to that one... And so on until it's done... And when target is reached, it goes for the next one... if that makes sense...
=) Hope this sparks an idea in the least... And don't worry about the money... Go and buy your girlfriend/wife dinner and tip the waiter/waitress the rest for me =).
Lol, I don't like giving people all the code for their problems, always thought they should work for it at the least... But meh, whatever =P. Your way works too =P, lol.
1+ for the generosity(I think that is the right word) :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613115740im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Car Selectin Script 1 Answer
Level Button And Quit Button Android 2 Answers
Problem with jcar script for android mobile 1 Answer
How to make android see game as game 1 Answer
do visual coding support android game 0 Answers