Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class AirtimeController : MonoBehaviour {
- public RaycastHit2D hit;
- public Ray2D downRay;
- LayerMask mask;
- public Vector2 rayDirection;
- public bool isGrounded;
- public GameObject carBody;
- public float tempAirTimeValue;
- public float speed;
- public int airTimeValue;
- public List<int> airTime = new List<int>();
- // Use this for initialization
- void Start ()
- {
- isGrounded = true;
- mask = LayerMask.NameToLayer("Default");
- }
- // Update is called once per frame
- void Update ()
- {
- downRay = new Ray2D(carBody.transform.position, Vector2.down);
- Debug.DrawRay(carBody.transform.position, Vector2.down * 10000, Color.green);
- // hit = Physics2D.Raycast(carBody.transform.position, Vector2.down);
- hit = Physics2D.Raycast(carBody.transform.position, Vector2.down, mask, 0, 0);
- // Debug.Log(hit.transform.name);
- if (hit.transform.name == "Hill")
- {
- Debug.Log("Hill Found");
- if(hit.distance > 5.0f)
- {
- isGrounded = false;
- }
- else
- {
- isGrounded = true;
- }
- }
- else
- {
- Debug.Log("No Hill Found");
- }
- //AirTimeChange();
- }
- void AirTimeChange()
- {
- if (!isGrounded)
- {
- airTimeValue = 0;
- tempAirTimeValue = 0;
- tempAirTimeValue = tempAirTimeValue + speed * Time.deltaTime;
- }
- else
- {
- airTimeValue = (int)tempAirTimeValue;
- Debug.Log(airTimeValue);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement