Refactoring camera on idle race.
This commit is contained in:
parent
5305e43ee1
commit
767cbdf205
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CameraFollower : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Transform _followTarget;
|
||||||
|
[SerializeField] private Camera _camera;
|
||||||
|
[SerializeField] private float _rotationSmooth;
|
||||||
|
[SerializeField] private float _positionSmooth;
|
||||||
|
|
||||||
|
private Vector3 _positionDiff;
|
||||||
|
private Quaternion _rotationDiff;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
_positionDiff = _camera.transform.position - _followTarget.position;
|
||||||
|
//_rotationDiff = _camera.transform.rotation - _followTarget.rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
_camera.transform.position = _followTarget.position + _positionDiff;
|
||||||
|
_camera.transform.LookAt(_followTarget);// = _followTarget.rotation + _rotationDiff;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 10ad62f1133f949458a04288c69535e0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 22cfd7759a248af45b90ca64ccb878bc
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5ed2a8cfc0f5c09488d353d30ab33cb6
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue