// Update is called once per frame void Update() { //******Camera movement****** float camYVal = Input.GetAxis(camY); if (camYVal != 0) { //Debug.Log("camY "+ camYVal); } float camXVal = Input.GetAxis(camX); if (camXVal != 0) { //Debug.Log("camX "+ camXVal); } if (camYVal != 0 || camXVal != 0) { //cc.RotateCamera(camYVal, camXVal); } // ******Car movement****** verticalVal = Input.GetAxis(vertical); horizontalVal = Input.GetAxis(horizontal); //Steering if (HasTiltedHorizontal) { dc.Steer(horizontalVal); } else { dc.Steer(0); } if (!IsGrounded && (HasTiltedHorizontal || HasTiltedVertical)) { //Debug.Log("air steer"); dc.AerialSteer(horizontalVal, verticalVal); } //Accelerate if (Input.GetButton(accelerate) && IsGrounded) { //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); cc.ChangeCameraViewToReverse(); } } if (Input.GetButtonUp(reverse)) { dc.Brake(0); dc.Reverse(0); } //*****Abilities***** if (Input.GetButton(jump) && upgrades.boosterRocketsEnabled) { dc.Rocket(); } //*****Abilities***** if (Input.GetButtonDown(DebugReset)) { //Debug.Log("Jump"); dc.ResetRotation(); } if (Input.GetButton(nitro) && upgrades.nitroBoostersEnabled) { gb.nitroBoost(); } //Check States IsGrounded = dc.CheckWheelsGrounded(); HasJumped = !IsGrounded; HasTiltedHorizontal = SetStickBool(horizontalVal); HasTiltedVertical = SetStickBool(verticalVal); }
// Update is called once per frame void Update() { //******Camera movement****** float camYVal = Input.GetAxis(camY); if (camYVal != 0) { //Debug.Log("camY "+ camYVal); } float camXVal = Input.GetAxis(camX); if (camXVal != 0) { //Debug.Log("camX "+ camXVal); } if (camYVal != 0 || camXVal != 0) { cc.RotateCamera(camYVal, camXVal); } if (Input.GetButtonDown(reset)) { //Debug.Log("Reset"); cc.ResetCameraRotation(); //sc.rotateCarTowardsHook(); } if (Input.GetKeyDown("z")) { Debug.Log("zooom"); cc.GoToFarView(); } // ******Car movement****** verticalVal = Input.GetAxis(vertical); horizontalVal = Input.GetAxis(horizontal); if (IsGrounded) { //Steering if (IsDriving && HasTiltedHorizontal) { dc.Steer(horizontalVal); Debug.Log("steer"); } 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) && IsGrounded) { //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)) { //Debug.Log("Shoot"); hb.ShootHook(); } if (Input.GetButtonDown(aimMode)) { //Debug.Log("Shoot"); cc.GoToAimView(); } //Check States IsGrounded = dc.CheckWheelsGrounded(); HasJumped = !IsGrounded; HasHit = hb.GetIsHooked(); HasTiltedHorizontal = SetStickBool(horizontalVal); HasTiltedVertical = SetStickBool(verticalVal); }
// 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); }