to new git

This commit is contained in:
2022-05-04 23:50:07 +07:00
parent 290f5515b7
commit c8af0e5284
39 changed files with 720 additions and 359 deletions

View File

@ -1,17 +1,16 @@
using System;
using UnityEngine;
using UnityEngine;
using static scr_Models;
public class scr_WeaponController : MonoBehaviour
{
private scr_CharacterController characterController;
[Header("Settings")]
[Header("Settings")]
public WeaponSettingsModel settings;
private bool isInitialised;
Vector3 newWeaponRotation;
Vector3 newWeaponRotationVelocity;
Vector3 targetWeaponRotation;
Vector3 targetWeaponRotationVelocity;
@ -32,17 +31,17 @@ public class scr_WeaponController : MonoBehaviour
{
return;
}
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;
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;
//newWeaponRotation.x = Mathf.Clamp(newWeaponRotation.x, ViewClampYMin, ViewClampYMax);
targetWeaponRotation.x = Mathf.Clamp(targetWeaponRotation.x, -settings.SwayClampX, settings.SwayClampX);
targetWeaponRotation.y = Mathf.Clamp(targetWeaponRotation.y, -settings.SwayClampY, settings.SwayClampY);
targetWeaponRotation = Vector3.SmoothDamp(targetWeaponRotation, Vector3.zero, ref targetWeaponRotationVelocity, settings.SwayResetSmoothing);
newWeaponRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
transform.localRotation = Quaternion.Euler(newWeaponRotation);
}
}