changed weapon

This commit is contained in:
2022-04-12 14:05:55 +07:00
parent 25cd6df71b
commit 95f61ab7e2
7 changed files with 211 additions and 253 deletions

View File

@ -11,7 +11,8 @@ public class scr_CharacterController : MonoBehaviour
private CharacterController characterController;
private DefaultInput defaultInput;
private Vector2 input_Movement;
[HideInInspector]
public Vector2 input_Movement;
[HideInInspector]
public Vector2 input_View;
@ -119,6 +120,7 @@ public class scr_CharacterController : MonoBehaviour
}
// Effectors
if (!characterController.isGrounded)
{
playerSettings.SpeedEffector = playerSettings.FallingSpeedEffector;

View File

@ -61,7 +61,7 @@ public static class scr_Models
[Serializable]
public class WeaponSettingsModel
{
[Header("Sway")]
[Header("Weapon Sway")]
public float SwayAmount;
public bool SwayYInverted;
public bool SwayXInverted;
@ -69,6 +69,13 @@ public static class scr_Models
public float SwayResetSmoothing;
public float SwayClampX;
public float SwayClampY;
[Header("Weapon Movement Sway")]
public float MovementSwayX;
public float MovementSwayY;
public bool MovementSwayYInverted;
public bool MovementSwayXInverted;
public float MovementSwaySmoothing;
}
#endregion

View File

@ -14,6 +14,12 @@ public class scr_WeaponController : MonoBehaviour
Vector3 targetWeaponRotation;
Vector3 targetWeaponRotationVelocity;
Vector3 newWeaponMovementRotation;
Vector3 newWeaponRotationMovementVelocity;
Vector3 targetWeaponMovementRotation;
Vector3 targetWeaponMovementRotationVelocity;
private void Start()
{
@ -40,8 +46,17 @@ 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);
}