Finally bots can die. Player to. And another fixes.
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using Animators.Leonid_Animator;
|
||||
using Animators.Leonid_Animator.Player;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
@ -7,50 +9,52 @@ namespace CameraScripts
|
||||
public class CameraHandler : MonoBehaviour
|
||||
{
|
||||
public Transform targetTransform;
|
||||
public Transform cameraTransform;
|
||||
public Transform cameraPivotTransform;
|
||||
private Transform _myTransform;
|
||||
private Vector3 _cameraTransformPosition;
|
||||
private LayerMask ignoreLayers = ~(1 << 8 | 1 << 9 | 1 << 10);
|
||||
[SerializeField] private Transform cameraTransform;
|
||||
|
||||
public static CameraHandler Singleton;
|
||||
|
||||
[SerializeField] private float LookSpeed = 0.1f;
|
||||
[SerializeField] private float FollowSpeed = 0.1f;
|
||||
[SerializeField] private float PivotSpeed = 0.03f;
|
||||
|
||||
private float _defaultPosition;
|
||||
private float _lookAngle;
|
||||
[SerializeField] private float lookSpeed = 0.1f;
|
||||
[SerializeField] private float followSpeed = 0.1f;
|
||||
[SerializeField] private float pivotSpeed = 0.03f;
|
||||
|
||||
public float LookAngle;
|
||||
private float _pivotAngle;
|
||||
|
||||
public float minimumPivot = -35;
|
||||
public float maximumPivot = 35;
|
||||
|
||||
private AnimatorHandler _animatorHandler;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Singleton = this;
|
||||
_myTransform = transform;
|
||||
_defaultPosition = _myTransform.localPosition.z;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_animatorHandler = gameObject.GetComponent<AnimatorHandler>();
|
||||
if (_animatorHandler == null)
|
||||
print(gameObject.name);
|
||||
}
|
||||
|
||||
public void TargetPosition(float delta)
|
||||
{
|
||||
var toTargetPosition = Vector3.Lerp(_myTransform.position, targetTransform.position, delta /FollowSpeed);
|
||||
var toTargetPosition = Vector3.Lerp(_myTransform.position, targetTransform.position, delta /followSpeed);
|
||||
_myTransform.position = toTargetPosition;
|
||||
}
|
||||
|
||||
public void HandleCameraRotation(float delta, float mouseX, float mouseY)
|
||||
{
|
||||
_lookAngle += (mouseX * LookSpeed) / delta;
|
||||
_pivotAngle -= (mouseY * PivotSpeed) / delta;
|
||||
LookAngle += (mouseX * lookSpeed) / delta;
|
||||
_pivotAngle -= (mouseY * pivotSpeed) / delta;
|
||||
_pivotAngle = Mathf.Clamp(_pivotAngle, minimumPivot, maximumPivot);
|
||||
|
||||
|
||||
var rotation = Vector3.zero;
|
||||
rotation.y = _lookAngle;
|
||||
var targetRotation = Quaternion.Euler(rotation);
|
||||
targetTransform.rotation = targetRotation;
|
||||
rotation.y = LookAngle;
|
||||
transform.rotation = Quaternion.Euler(rotation);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user