Настроенные авто
This commit is contained in:
parent
ce43ecdef8
commit
1040da0484
@ -1,27 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class CameraObjec : MonoBehaviour
|
|
||||||
{
|
|
||||||
public Transform player;
|
|
||||||
private Rigidbody playerRB;
|
|
||||||
public Vector3 Offset;
|
|
||||||
public float speed;
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
playerRB = player.GetComponent<Rigidbody>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void FixedUpdate()
|
|
||||||
{
|
|
||||||
Vector3 playerForward = (playerRB.velocity + player.transform.forward).normalized;
|
|
||||||
transform.position = Vector3.Lerp(transform.position,
|
|
||||||
player.position + player.transform.TransformVector(Offset)
|
|
||||||
+ playerForward * (-5f),
|
|
||||||
speed * Time.deltaTime);
|
|
||||||
transform.LookAt(player);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6482ad70cbb280a41b1911ed2b71f491
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -24,7 +24,6 @@ namespace RootMotion
|
|||||||
|
|
||||||
[Header("Position")]
|
[Header("Position")]
|
||||||
public bool smoothFollow; // If > 0, camera will smoothly interpolate towards the target
|
public bool smoothFollow; // If > 0, camera will smoothly interpolate towards the target
|
||||||
public Vector3 offset = new Vector3(0, 1.5f, 0.5f); // The offset from target relative to camera rotation
|
|
||||||
public float followSpeed = 10f; // Smooth follow speed
|
public float followSpeed = 10f; // Smooth follow speed
|
||||||
|
|
||||||
[Header("Rotation")]
|
[Header("Rotation")]
|
||||||
@ -45,7 +44,6 @@ namespace RootMotion
|
|||||||
public float blockingRadius = 1f;
|
public float blockingRadius = 1f;
|
||||||
public float blockingSmoothTime = 0.1f;
|
public float blockingSmoothTime = 0.1f;
|
||||||
public float blockingOriginOffset;
|
public float blockingOriginOffset;
|
||||||
[Range(0f, 1f)] public float blockedOffset = 0.5f;
|
|
||||||
|
|
||||||
public float x { get; private set; } // The current x rotation of the camera
|
public float x { get; private set; } // The current x rotation of the camera
|
||||||
public float y { get; private set; } // The current y rotation of the camera
|
public float y { get; private set; } // The current y rotation of the camera
|
||||||
@ -59,7 +57,6 @@ namespace RootMotion
|
|||||||
private float fixedDeltaTime;
|
private float fixedDeltaTime;
|
||||||
private Quaternion r = Quaternion.identity;
|
private Quaternion r = Quaternion.identity;
|
||||||
private Vector3 lastUp;
|
private Vector3 lastUp;
|
||||||
private float blockedDistance = 10f, blockedDistanceV;
|
|
||||||
|
|
||||||
//Rotation
|
//Rotation
|
||||||
|
|
||||||
@ -79,31 +76,19 @@ namespace RootMotion
|
|||||||
// Initiate, set the params to the current transformation of the camera relative to the target
|
// Initiate, set the params to the current transformation of the camera relative to the target
|
||||||
protected virtual void Awake()
|
protected virtual void Awake()
|
||||||
{
|
{
|
||||||
Vector3 angles = transform.eulerAngles;
|
//Vector3 angles = transform.eulerAngles;
|
||||||
x = angles.y;
|
//x = angles.y;
|
||||||
y = angles.x;
|
//y = angles.x;
|
||||||
|
|
||||||
distanceTarget = distance;
|
distanceTarget = distance;
|
||||||
smoothPosition = transform.position;
|
smoothPosition = transform.position;
|
||||||
|
|
||||||
cam = GetComponent<Camera>();
|
cam = GetComponent<Camera>();
|
||||||
|
|
||||||
//_rotate = new Controller();
|
|
||||||
//_rotate.Player.CameraRotation.performed += context => UpdateInput();
|
|
||||||
|
|
||||||
|
|
||||||
//lastUp = rotationSpace != null ? rotationSpace.up : Vector3.up;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void OnEnable()
|
|
||||||
//{
|
|
||||||
// _rotate.Enable();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//private void OnDisable()
|
|
||||||
//{
|
|
||||||
// _rotate.Disable();
|
|
||||||
//}
|
|
||||||
|
|
||||||
protected virtual void Update()
|
protected virtual void Update()
|
||||||
{
|
{
|
||||||
@ -174,33 +159,11 @@ namespace RootMotion
|
|||||||
// Distance
|
// Distance
|
||||||
distance += (distanceTarget - distance) * zoomSpeed * deltaTime;
|
distance += (distanceTarget - distance) * zoomSpeed * deltaTime;
|
||||||
|
|
||||||
// Smooth follow
|
|
||||||
if (!smoothFollow) smoothPosition = target.position;
|
|
||||||
else smoothPosition = Vector3.Lerp(smoothPosition, target.position, deltaTime * followSpeed);
|
|
||||||
|
|
||||||
// Position
|
|
||||||
Vector3 t = smoothPosition + rotation * offset;
|
|
||||||
Vector3 f = rotation * -Vector3.forward;
|
|
||||||
|
|
||||||
if (blockingLayers != -1)
|
|
||||||
{
|
|
||||||
RaycastHit hit;
|
|
||||||
if (Physics.SphereCast(t - f * blockingOriginOffset, blockingRadius, f, out hit, blockingOriginOffset + distanceTarget - blockingRadius, blockingLayers))
|
|
||||||
{
|
|
||||||
blockedDistance = Mathf.SmoothDamp(blockedDistance, hit.distance + blockingRadius * (1f - blockedOffset) - blockingOriginOffset, ref blockedDistanceV, blockingSmoothTime);
|
|
||||||
}
|
|
||||||
else blockedDistance = distanceTarget;
|
|
||||||
|
|
||||||
distance = Mathf.Min(distance, blockedDistance);
|
|
||||||
}
|
|
||||||
|
|
||||||
position = t + f * distance;
|
|
||||||
|
|
||||||
// Translating the camera
|
|
||||||
transform.position = position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.rotation = rotation;
|
//transform.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zoom input
|
// Zoom input
|
||||||
|
@ -110,7 +110,7 @@ public class DriftScore : MonoBehaviour
|
|||||||
|
|
||||||
void ManageUI()
|
void ManageUI()
|
||||||
{
|
{
|
||||||
totalScoreText.text = "Ðåêîðä: " + (totalScore).ToString("###,###, ##0");
|
totalScoreText.text = "Î÷êè: " + (totalScore).ToString("###,###, ##0");
|
||||||
factorText.text = driftFactor.ToString("###,###,##0.0") + "X";
|
factorText.text = driftFactor.ToString("###,###,##0.0") + "X";
|
||||||
currentScoreText.text = currentScore.ToString("###,###,000");
|
currentScoreText.text = currentScore.ToString("###,###,000");
|
||||||
driftAngleText.text = driftAngle.ToString("###,##0");
|
driftAngleText.text = driftAngle.ToString("###,##0");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user