private void pointTimer() { mTimer -= Time.deltaTime; if (mTimer < 0) { mTimer = mRecoveryTimer; m_trickController.popPointsTimer("Horse Spinner", 1000, Color.blue); //Debug.Log("add points"); } }
// Update is called once per frame void Update() { //Can the player move and take control? if (canMove == true) { #if UNITY_STANDALONE || UNITY_XBOXONE hAxis = Input.GetAxis("Horizontal"); vAxis = Input.GetAxis("Vertical"); rightHAxis = Input.GetAxis("Horizontal2"); rightVAxis = Input.GetAxis("Vertical2"); #endif //check the horses velocity velocityCheck(); //check to see if we are touching the ground or a rail RaycastHit hit; Debug.DrawRay(transform.position, -Vector3.up * rayDistance, Color.green); if (Physics.Raycast(transform.position, -Vector3.up, out hit, rayDistance)) { //HIT SOMETHING //Did we hit a rail? if (hit.transform.tag == "Rail") { isGrounded = false; if (hasGivenRailPoints == false) { //give rail points hasGivenRailPoints = true; _trickController.popPointsTimer("Hay Slide", 3400, Color.black); } } else { //camera shake if our point value is legit //TODO: Took this out because it doesn't work at all /* * if(_trickController.m_trickValue >= 1000) * { * iTween.ShakePosition(m_camera, new Vector3(0.01f, * 0.01f, * 0.01f), * 0.1f); * } */ //No we didn't hit a rail! We touched the ground!! _trickController.endTrickTimer(); _trickController.m_trickValue = 0; _trickController.m_numOfTricks = 1; isGrounded = true; //give back rail point privledges since we have landed hasGivenRailPoints = false; if (transform.localEulerAngles.y > 260 && transform.localEulerAngles.y < 320) { _rigid.AddTorque(transform.up * 8000 * Time.deltaTime); //Debug.Log("Correct right"); } else if (transform.localEulerAngles.y > 30 && transform.localEulerAngles.y < 140) { _rigid.AddTorque(-transform.up * 8000 * Time.deltaTime); //Debug.Log("CORRECT left!"); } else { _rigid.angularVelocity = Vector3.zero; } } } else { isGrounded = false; } //is the player in the air? if (isGrounded == false) { //flip back or forward flipControl(); //rotate control rotateControl(); //allow the player to do tricks trickControls(); } else { //allow the player to jump JumpControls(); _rigid.angularVelocity = Vector3.zero; } } else { //the player is not ready to play. Disable the rigidbody _rigid.isKinematic = true; } }