// Update is called once per frame void Update() { verticalVal = Input.GetAxis(vertical); horizontalVal = Input.GetAxis(horizontal); camYVal = Input.GetAxis(camY); camXVal = Input.GetAxis(camX); //on the ground //in the air // aiming //when aiming in the air //when swinging //******Camera movement****** CameraControl(); // ******Car movement****** if (IsGrounded) { //Steering if (IsDriving && HasTiltedHorizontal) { dc.Steer(horizontalVal); } else { dc.Steer(0); } //turning if (!IsDriving && HasTiltedHorizontal) { dc.Turn(horizontalVal); } else { dc.ResetTurningStiffness(); } } else if (!IsGrounded && (HasTiltedHorizontal || HasTiltedVertical)) { //Debug.Log("air steer"); dc.AerialSteer(horizontalVal, verticalVal); } //Accelerate if (Input.GetButton(accelerate)) { //Debug.Log("Accelerate"); IsDriving = true; dc.Accelerate(1); } if (Input.GetButtonUp(accelerate)) { //Debug.Log("Accelerate"); dc.Accelerate(0); } //Reverse or Brake if (Input.GetButtonDown(reverse)) { if (IsDriving) { BrakeNotReverse = true; } else { BrakeNotReverse = false; } } if (Input.GetButton(reverse) && IsGrounded) { if (BrakeNotReverse) { //Debug.Log("Brake"); dc.Brake(1); } else { IsDriving = true; dc.Reverse(1); } } if (Input.GetButtonUp(reverse)) { dc.Brake(0); dc.Reverse(0); } //*****Abilities***** if (Input.GetButtonDown(jump) && !HasJumped) { //Debug.Log("Jump"); dc.Jump(); HasJumped = true; } if (Input.GetButtonDown(shoot)) { hb.ResetHook(); if (!IsGrounded) { dc.StopCarTorque(); cc.AddCameraRotationToPlayer(); } hb.SetCrosshair(true); cc.GoToAimView(); } if (Input.GetButton(shoot)) { hb.HookRayCast(); } if (Input.GetButtonUp(shoot)) { hb.ShootHook(); if (hb.GetIsHooked()) { cc.GoToFarView(); } else { cc.GoToDefView(); } hb.SetCrosshair(false); } if (Input.GetButtonDown(aimMode)) { //Debug.Log("Shoot"); cc.GoToFarView(); } //Check States IsGrounded = dc.CheckWheelsGrounded(); HasJumped = !IsGrounded; IsHooked = hb.GetIsHooked(); HasTiltedHorizontal = SetStickBool(horizontalVal); HasTiltedVertical = SetStickBool(verticalVal); }