Add SFX to dialogue, revamp control scheme (broken world map camera)
This commit is contained in:
30
Assets/Scripts/Camera/CameraFollow.cs
Normal file
30
Assets/Scripts/Camera/CameraFollow.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class CameraFollow : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform targetObject;
|
||||
[SerializeField]
|
||||
private Vector3 cameraOffset;
|
||||
[SerializeField]
|
||||
private float smoothFactor = 0.5f;
|
||||
[SerializeField]
|
||||
private bool lookAtTarget = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cameraOffset = transform.position - targetObject.transform.position;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (lookAtTarget)
|
||||
transform.LookAt(targetObject);
|
||||
|
||||
var newPosition = targetObject.transform.position + cameraOffset;
|
||||
transform.position = Vector3.Slerp(transform.position, newPosition, smoothFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user