Есть классы, есть двери, есть механика вселения, свага есть

This commit is contained in:
vladislove committed 2026-10-21 21:21:16 +03:00
1 parent 2ae795c30a
commit 0f9a539460
69 files changed
+3960 -299

No files matched your search

@@ -1,5 +1,4 @@
using UnityEngine;
using UnityEngine.InputSystem;
namespace _Project.Scripts.PlayerUtils
{
@@ -24,6 +23,8 @@ namespace _Project.Scripts.PlayerUtils
[SerializeField] private float sprintBobAmount = 0.07f;
[SerializeField] private float impactRecoverySpeed = 6f;
public Transform CameraTransform => cameraPosition;
private PlayerControls controls;
private PlayerMovement movement;
@@ -47,6 +48,23 @@ namespace _Project.Scripts.PlayerUtils
yRotation = transform.eulerAngles.y;
}
public void ApplyProfile(BodyProfile profile)
{
standingCameraY = profile.standingCameraY;
crouchingCameraY = profile.crouchingCameraY;
walkBobSpeed = profile.walkBobSpeed;
sprintBobSpeed = profile.walkBobSpeed * 1.25f;
walkBobAmount = profile.walkBobAmount;
sprintBobAmount = profile.walkBobAmount * 1.6f;
slideCameraTiltAngle = profile.slideTiltAngle;
}
public void SetYaw(float yaw)
{
yRotation = yaw;
transform.rotation = Quaternion.Euler(0f, yRotation, 0f);
}
private void Update()
{
HandleMouseLook();
@@ -56,12 +74,13 @@ namespace _Project.Scripts.PlayerUtils
private void HandleMouseLook()
{
Vector2 lookInput = controls.Player.Look.ReadValue<Vector2>();
float dt = Time.unscaledDeltaTime;
cameraPitch -= lookInput.y * mouseSensitivity;
cameraPitch = Mathf.Clamp(cameraPitch, -maxLookAngle, maxLookAngle);
float targetTilt = movement.IsSliding ? -slideCameraTiltAngle : 0f;
currentCameraTilt = Mathf.Lerp(currentCameraTilt, targetTilt, Time.deltaTime * 10f);
currentCameraTilt = Mathf.Lerp(currentCameraTilt, targetTilt, dt * 10f);
cameraPosition.localRotation = Quaternion.Euler(cameraPitch, 0f, currentCameraTilt);
@@ -71,9 +90,10 @@ namespace _Project.Scripts.PlayerUtils
private void HandleCameraAndBobbing()
{
float dt = Time.unscaledDeltaTime;
bool isLowered = movement.IsCrouching || movement.IsSliding;
float targetCamY = isLowered ? crouchingCameraY : standingCameraY;
baseCameraY = Mathf.Lerp(baseCameraY, targetCamY, Time.deltaTime * crouchTransitionSpeed);
baseCameraY = Mathf.Lerp(baseCameraY, targetCamY, dt * crouchTransitionSpeed);
bool isMoving = movement.MoveInput.sqrMagnitude > 0.01f && movement.IsGrounded && !movement.IsSliding;
@@ -82,13 +102,12 @@ namespace _Project.Scripts.PlayerUtils
float speed = movement.IsSprinting ? sprintBobSpeed : walkBobSpeed;
float amount = movement.IsSprinting ? sprintBobAmount : walkBobAmount;
bobTimer += Time.deltaTime * speed;
bobTimer += dt * speed;
bobOffset.x = Mathf.Cos(bobTimer * 0.5f) * amount;
bobOffset.y = Mathf.Sin(bobTimer) * amount;
if (Mathf.Sin(bobTimer) <= -0.9f && !stepTaken)
{
// ВЫЗОВ ЗВУКА ИЗ НОВОГО МОДУЛЯ
Player.Instance.Sound.PlayFootstep(movement.IsSprinting);
stepTaken = true;
}
@@ -98,10 +117,10 @@ namespace _Project.Scripts.PlayerUtils
{
bobTimer = 0f;
stepTaken = false;
bobOffset = Vector3.Lerp(bobOffset, Vector3.zero, Time.deltaTime * 10f);
bobOffset = Vector3.Lerp(bobOffset, Vector3.zero, dt * 10f);
}
currentImpactOffset = Mathf.Lerp(currentImpactOffset, 0f, Time.deltaTime * impactRecoverySpeed);
currentImpactOffset = Mathf.Lerp(currentImpactOffset, 0f, dt * impactRecoverySpeed);
cameraPosition.localPosition = new Vector3(bobOffset.x, baseCameraY + bobOffset.y - currentImpactOffset, 0f);
}