Guest User

Untitled

a guest
Aug 30th, 2015
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Paths
  3. var Paths : Array;
  4. var PathGroup : Transform;
  5. var CurrentPathObj : int;
  6. var DistanceFromPath : float = 20;
  7.  
  8.  
  9. function GetPath(){
  10.     var Path_Objs : Array = PathGroup.GetComponentsInChildren(Transform);
  11.         Paths = new Array();
  12.        
  13.         for(var Path_Obj : Transform in Path_Objs){
  14.             if (Path_Obj != PathGroup){
  15.                 Paths [Paths.length] = Path_Obj;
  16.             }
  17.            
  18.         //Debug.Log(Paths.length);
  19.         }
  20. }
  21.  
  22. function GetSteer(){
  23.     var SteerVector : Vector3 = transform.InverseTransformPoint(Vector3(Paths[CurrentPathObj].position.x, transform.position.y, Paths[CurrentPathObj].position.z));
  24.     var NewSteer : float = MaxSteer * (SteerVector.x / SteerVector.magnitude);
  25.     WheelFL.steerAngle = NewSteer;
  26.     WheelFR.steerAngle = NewSteer;
  27.    
  28.     if(SteerVector.magnitude <= DistanceFromPath){
  29.         CurrentPathObj ++;
  30.        
  31.         if(CurrentPathObj >= Paths.length){
  32.             CurrentPathObj = 0;
  33.        
  34.         }
  35.     }
  36. }
RAW Paste Data