Hey Guys,
Im following some tutorials online about waypoints. I have got something working where my Ai moves to the way points in order of the array. But Ive been trying to figure out how to many it RANDOMLY pick between way points…any ideas on how to do this any help would be really appreciated.
Heres the code:
var waypoint:Transform[ ];
var speed:float = 20;
private var currentWaypoint: int;
function Update ()
{
if (currentWaypoint < waypoint.length)
{
var target : Vector3 = waypoint[currentWaypoint].position;
var moveDirection : Vector3 = target - transform.position;
var velocity = rigidbody.velocity;
if (moveDirection.magnitude < 1)
{
currentWaypoint.Random.Range++;
}
else
{
velocity = moveDirection.normalized * speed;
}
}
rigidbody.velocity = velocity;
}