Advertisement
moinularif

AirTimeContriller

Sep 3rd, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class AirtimeController : MonoBehaviour {
  6.  
  7.  
  8.    public  RaycastHit2D hit;
  9.    public Ray2D downRay;
  10.  
  11.     public Vector2 rayDirection;
  12.    
  13.     public bool isGrounded;
  14.  
  15.     public GameObject carBody;
  16.  
  17.     public float tempAirTimeValue;
  18.     public float speed;
  19.     public int airTimeValue;
  20.  
  21.     public List<int> airTime = new List<int>();
  22.     // Use this for initialization
  23.     void Start ()
  24.     {
  25.         isGrounded = true;
  26.        
  27.     }
  28.    
  29.     // Update is called once per frame
  30.     void Update ()
  31.     {
  32.         downRay = new Ray2D(carBody.transform.position, Vector2.down);
  33.  
  34.         Debug.DrawRay(carBody.transform.position, Vector2.down * 10000, Color.green);
  35.  
  36.  
  37.         hit = Physics2D.Raycast(carBody.transform.position, Vector2.down);
  38.  
  39.        // Debug.Log(hit.transform.name);
  40.         if (hit.transform.name == "Hill")
  41.         {
  42.             Debug.Log("Hill Found");
  43.             if(hit.distance > 5.0f)
  44.             {
  45.                 isGrounded = false;
  46.             }
  47.             else
  48.             {
  49.                 isGrounded = true;
  50.             }
  51.         }
  52.        
  53.         //AirTimeChange();
  54.     }
  55.  
  56.     void AirTimeChange()
  57.     {
  58.         if (!isGrounded)
  59.         {
  60.             airTimeValue = 0;
  61.             tempAirTimeValue = 0;
  62.             tempAirTimeValue = tempAirTimeValue + speed * Time.deltaTime;
  63.  
  64.         }
  65.         else
  66.         {
  67.             airTimeValue = (int)tempAirTimeValue;
  68.             Debug.Log(airTimeValue);
  69.  
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement