Fix World Camera
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
@@ -13,20 +12,19 @@ namespace Scampz.GameJam
|
||||
private float smoothFactor = 0.5f;
|
||||
[SerializeField]
|
||||
private bool lookAtTarget = false;
|
||||
[SerializeField]
|
||||
private float _cameraYPosition = 45f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//cameraOffset = transform.position - targetObject.transform.position;
|
||||
transform.position = targetObject.transform.position - cameraOffset;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (lookAtTarget)
|
||||
transform.LookAt(targetObject);
|
||||
|
||||
var newPosition = targetObject.transform.position + cameraOffset;
|
||||
var absTransform = new Vector3(newPosition.x, Math.Abs(newPosition.y), newPosition.z);
|
||||
transform.position = Vector3.Slerp(transform.position, newPosition, smoothFactor);
|
||||
var lockedInYPosition = new Vector3(targetObject.transform.position.x - cameraOffset.x, _cameraYPosition, targetObject.transform.position.z - cameraOffset.z);
|
||||
transform.position = lockedInYPosition;
|
||||
transform.LookAt(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user