Graphics Reference
In-Depth Information
Vector3 relativeTarget = myTransform.InverseTransformPoint
(currentWaypointTransform.position);
// Calculate the target angle for the wheels,
// so they point towards the target
targetAngle = Mathf.Atan2 (relativeTarget.x,
relativeTarget.z);
// Atan returns the angle in radians, convert to degrees
targetAngle *= Mathf.Rad2Deg;
if(targetAngle<-90 || targetAngle>90){
goingWrongWay=true;
} else {
goingWrongWay=false;
timeWrongWayStarted=-1;
}
if(oldWrongWay!=goingWrongWay)
{
// store the current time
timeWrongWayStarted= Time.time;
}
oldWrongWay=goingWrongWay;
}
public void OnTriggerEnter( Collider other )
{
// if the trigger we just hit is the start line trigger, we
// can increase our lap counter when lapDone is true
// check the name of the trigger and make sure lapDone is
// true
if(
other.name=="TRIGGER_STARTLINE" && isLapDone==true)
{
// increase lap counter
lapsComplete++;
// reset our lapDone flag ready for when we finish
// the next lap
isLapDone=false;
// tell race controller we just finished a lap and
// which lap we are now on
GlobalRaceManager.Instance.CompletedLap(myID);
// not the cleanest solution, but it means we don't
// have to hardwire in the game controller script
// type or the player control script at least. Here,
// we take our object and do a SendMessage call to
// it, to say the lap finished
gameObject.SendMessageUpwards("LapFinished",SendMess
ageOptions.DontRequireReceiver);
}
}
}
Search WWH ::




Custom Search