Graphics Reference
In-Depth Information
{
currentWaypointNum=0;
currentWaypointTransform=waypointManager.GetWaypoint
(currentWaypointNum);
}
// now we need to check to see if we are close enough to the
// current waypoint to advance on to the next one
myPosition = myTransform.position;
myPosition.y=0;
// get waypoint position and 'flatten' it
nodePosition = currentWaypointTransform.position;
nodePosition.y=0;
// check distance from this car to the waypoint
currentWaypointDist = Vector3.Distance(nodePosition,
myPosition);
if (currentWaypointDist < waypointDistance) {
// we are close to the current node, so let's move
// on to the next one!
currentWaypointNum++;
// now check to see if we have been all the way
// around the track and need to start again
if(currentWaypointNum>=totalWaypoints){
// completed a lap! set the lapDone flag to
// true, which will be checked when we go over
// the first waypoint (so that you can't
// almost complete a race then go back around
// the other way to confuse it)
isLapDone=true;
// reset our current waypoint to the first
// one again
currentWaypointNum=0;
}
// grab our transform reference from the waypoint
// controller
currentWaypointTransform=waypointManager.GetWaypoint(currentWaypointNum);
}
// position our debug box at the current waypoint so we can
// see it (uncomment if you're debugging!)
// debugBox.transform.position=currentWaypointTransform.position;
}
public void CheckWrongWay()
{
if(currentWaypointTransform==null)
return;
Search WWH ::




Custom Search