Машина, камера, мотор
This commit is contained in:
1 parent
b54083521f
commit
a45223d0e7
48 files changed
+5507
-3735
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using Code.Infrastructure.Generators;
|
||||
using DG.Tweening;
|
||||
using Code.Infrastructure.Generators;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Infrastructure.Camera.CameraStates
|
||||
@@ -23,70 +22,21 @@ namespace Code.Infrastructure.Camera.CameraStates
|
||||
protected override void HandleRotationInput(float deltaTime, Vector3 rotationInput, out Quaternion q)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
private Transform _carTarget;
|
||||
private Rigidbody _carRigidbody;
|
||||
|
||||
public void SetFollowTarget(Transform carTarget, Rigidbody carRigidbody)
|
||||
{
|
||||
_carTarget = carTarget;
|
||||
_carRigidbody = carRigidbody;
|
||||
}
|
||||
|
||||
private Vector3 _lookAtOffset = new Vector3(0, 1.5f, 0);
|
||||
}
|
||||
|
||||
protected override void HandlePosition(float deltaTime, object targetRotation)
|
||||
{
|
||||
Fuck();
|
||||
}
|
||||
|
||||
private void Fuck()
|
||||
{
|
||||
// Автоматическое вращение вокруг машины
|
||||
Vector3 targetPosition = CalculateFollowPosition();
|
||||
|
||||
// Плавное перемещение
|
||||
{
|
||||
|
||||
Vector3 velocity = _carRigidbody ? _carRigidbody.linearVelocity : new Vector3();
|
||||
// Context.cameraLoadedData.Camera.transform.DOMove(targetPosition,
|
||||
// Context.cameraLoadedData.SettingsConfigs[CameraMode.ThirdPerson].followSharpness);
|
||||
Context.cameraLoadedData.Camera.transform.position = Vector3.SmoothDamp(
|
||||
Context.cameraLoadedData.Camera.transform.position,
|
||||
targetPosition,
|
||||
ref velocity,
|
||||
Context.cameraLoadedData.SettingsConfigs[CameraMode.ThirdPerson].followSharpness
|
||||
);
|
||||
|
||||
// Направление взгляда с опережением
|
||||
Vector3 lookTarget = _carTarget.position +
|
||||
_carTarget.forward * Context.cameraLoadedData.SettingsConfigs[CameraMode.ThirdPerson].defaultDistance +
|
||||
_lookAtOffset;
|
||||
|
||||
Context.cameraLoadedData.Camera.transform.LookAt(lookTarget);
|
||||
}
|
||||
|
||||
private Vector3 _followOffset = new Vector3(0, 3, -8);
|
||||
|
||||
private Vector3 CalculateFollowPosition()
|
||||
{
|
||||
Vector3 basePosition = _carTarget.position +
|
||||
_carTarget.TransformDirection(_followOffset);
|
||||
|
||||
// Динамическое смещение на основе скорости
|
||||
if (!_carRigidbody) return basePosition;
|
||||
|
||||
var speedFactor = Mathf.Clamp01(_carRigidbody.linearVelocity.magnitude / 50f);
|
||||
var speedOffset = _carTarget.forward * (speedFactor * -3f);
|
||||
basePosition += speedOffset;
|
||||
|
||||
return basePosition;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void LateUpdate()
|
||||
{
|
||||
Fuck();
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user