Merge branch 'krazerleo/core/1' into enikeev/dev/2

This commit is contained in:
Enikeevtimur
2022-05-10 01:03:12 +07:00
176 changed files with 10280 additions and 7411 deletions

View File

@ -1,18 +1,10 @@
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using static scr_Models;
using UnityEngine;
public class scr_WeaponController : MonoBehaviour
{
private scr_CharacterController characterController;
[Header("Settings")]
public WeaponSettingsModel settings;
[Header("References")]
public Animator weaponAnimator;
private bool isInitialised;
Vector3 newWeaponRotation;
@ -21,11 +13,6 @@ public class scr_WeaponController : MonoBehaviour
Vector3 targetWeaponRotation;
Vector3 targetWeaponRotationVelocity;
Vector3 newWeaponMovementRotation;
Vector3 newWeaponRotationMovementVelocity;
Vector3 targetWeaponMovementRotation;
Vector3 targetWeaponMovementRotationVelocity;
private void Start()
{
newWeaponRotation = transform.localRotation.eulerAngles;
@ -44,13 +31,6 @@ public class scr_WeaponController : MonoBehaviour
return;
}
CalculateWeaponRotation();
SetWeaponAnimation();
}
private void CalculateWeaponRotation()
{
weaponAnimator.speed = characterController.weaponAnimationSpeed;
targetWeaponRotation.y += settings.SwayAmount * (settings.SwayXInverted ? -characterController.input_View.x : characterController.input_View.x) * Time.deltaTime;
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;
//newWeaponRotation.x = Mathf.Clamp(newWeaponRotation.x, ViewClampYMin, ViewClampYMax);
@ -58,23 +38,9 @@ public class scr_WeaponController : MonoBehaviour
targetWeaponRotation.x = Mathf.Clamp(targetWeaponRotation.x, -settings.SwayClampX, settings.SwayClampX);
targetWeaponRotation.y = Mathf.Clamp(targetWeaponRotation.y, -settings.SwayClampY, settings.SwayClampY);
targetWeaponRotation.z = targetWeaponRotation.y;
targetWeaponRotation = Vector3.SmoothDamp(targetWeaponRotation, Vector3.zero, ref targetWeaponRotationVelocity, settings.SwayResetSmoothing);
newWeaponRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
targetWeaponMovementRotation.z = settings.MovementSwayX * (settings.MovementSwayXInverted ? -characterController.input_Movement.x : characterController.input_Movement.x);
targetWeaponMovementRotation.x = settings.MovementSwayY * (settings.MovementSwayYInverted ? -characterController.input_Movement.y : characterController.input_Movement.y);
targetWeaponMovementRotation = Vector3.SmoothDamp(targetWeaponMovementRotation, Vector3.zero, ref targetWeaponMovementRotationVelocity, settings.SwayResetSmoothing);
newWeaponMovementRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponMovementRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
transform.localRotation = Quaternion.Euler(newWeaponRotation);
}
private void SetWeaponAnimation()
{
weaponAnimator.SetBool("isSprinting", characterController.isSprinting);
}
}
}