so i am making a racing game, but i cant seem to create a waypoint for the AI Cars. i have itween visual editor but since i am a noob at this i cant seem to find a waypoint script in the files. is there a script in there i am just too blind to see, or is there a script i have to create and put in?
I took this from Unity’s FPS tutorial. Even though it is for a FPS, it isn’t too difficult to transfer the idea to your unique game. http://download.unity3d.com/support/old-resources/files/FPS_Tutorial_3.pdf First section is “Waypoints”, you will have to download the FPS_Complete and look up the script to see it.
create a few empty gameobjects and label them waypoint1, waypoint2 etc. then make another empty gameobject and put a collider on it and check the trigger box, then put this script on the trigger
var waypoint1 : Transform;
var waypoint2 : Transform;
var waypoint3 : Transform;
//extend this if you want
var waypoint = 1;
function Start () {
transform.Position = waypoint1.position;
}
function Update () {
// extend this part too if you extended the top
if(waypoint == 2){
transform.Position = waypoint2.position;
}
if(waypoint == 3){
transform.Position = waypoint3.position;
}
}
//im assuming your car has a collider
function OnTriggerEnter () {
waypoint += 1;
}
then put this on the AI car
var trigger : Transform;
//make sure you assign the objects to the script in the editor
function Update () {
transform.LookAt(trigger);
}
note that this wont look very realistic because the car will turn instantly.
you could try RotateTowards but i didnt use it because i have never been able to get it to work