- Home /
Unity Car tutorial, Wrong way code
Hello, I'm trying to add wrong way check to car tutorial, following the instruction on this forum post http://forum.unity3d.com/threads/16706-And-the-winner-is... i added waypoint to the terrain and here is my code
trackDir = NextwayPoints.transform.position - CurrentWayPoint.transform.position;
trackDir.Normalize();
xx = Vector3.Dot(this.transform.forward, trackDir);
if ( xx< 0)
{
wrongWay = true;
}
else
wrongWay = false;
this script is attached to the car in the tutorial, now it works in perfect way as long as its the straight road on the track but once i enter the u turn and sharp turns the code doesnt work any more ... is there somthing wrong with the code ?
The code looks correct in principle; however, it may be sensitive to waypoint spacing. Can you clarify what you mean by 'doesn't work'? Have you tried debugging the code or adding debug output? What did you find out?
Your answer
Follow this Question
Related Questions
AI faces Weird Direction when following a waypoint 0 Answers
City traffic Lanes 3 Answers
Pointing towards Waypoint 2 Answers
Waypoint System Does Not Rotate Enemy? 2 Answers