private void Update() { isAiming = Input.GetMouseButton(1); animator.SetBool(isAimingParam, isAiming); var weapon = activeWeapon.GetActiveWeapon(); if (weapon) { weapon.recoil.recoilModifier = isAiming ? 0.3f : 1.0f; } xAxis.Update(Time.fixedDeltaTime); yAxis.Update(Time.fixedDeltaTime); float max = yAxis.m_MaxValue = 90; float min = yAxis.m_MinValue = -90; cameraLookAt.eulerAngles = new Vector3(Mathf.Clamp(yAxis.Value, min, max), xAxis.Value, 0); //Rotation of camera in Y axis float yawCamera = mainCamera.transform.rotation.eulerAngles.y; //Blend from current rotation towards the cams rotatiion only in y axis transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime); }
// Update is called once per frame void Update() { RaycastWeapon weapon = activeWeapon.GetActiveWeapon(); if (weapon) { if (Input.GetKeyDown(KeyCode.R) || weapon.ammoCount <= 0) { rigcontroller.SetTrigger("reload_weapon"); isReloading = true; } if (weapon.isFiring) { ammoWidget.Refresh(weapon.ammoCount); } } }
private void Update() { #region recoil //isAiming = Input.GetMouseButton(1); animator.SetBool(isAimingParam, isAiming); var weapon = activeWeapon.GetActiveWeapon(); if (weapon) { weapon.recoil.recoilModifier = isAiming ? 0.3f : 1.0f; } #endregion if (desktopControlls.DesktopControlls) { //Debug.Log(desktopControlls.DesktopControlls); #region Camera Aiming Desktop xAxis.Update(Time.fixedDeltaTime); yAxis.Update(Time.fixedDeltaTime); cameraLookAt.eulerAngles = new Vector3(yAxis.Value, xAxis.Value, 0); //Rotation of camera in Y axis float yawCamera = mainCamera.transform.rotation.eulerAngles.y; //Blend from current rotation towards the cams rotatiion only in y axis transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime); #endregion } else { #region MOBILE AIMING CODE WORKING if (Input.touchCount > 0) { if ((Input.touches[0].position.x > Screen.width / 2 && Input.touches[0].phase == TouchPhase.Moved) || (Input.touches[1].position.x > Screen.width / 2 && Input.touches[1].phase == TouchPhase.Moved)) { #region TESTING CODE 5 xAxis.Update(Time.fixedDeltaTime); yAxis.Update(Time.fixedDeltaTime); cameraLookAt.eulerAngles = new Vector3(yAxis.Value, xAxis.Value, 0); //Rotation of camera in Y axis float yawCamera = mainCamera.transform.rotation.eulerAngles.y; //Blend from current rotation towards the cams rotatiion only in y axis transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime); #endregion } } #endregion } }