1
This commit is contained in:
21
unity/Assets/2.5D Engine/Scripts/CameraFollow.cs
Normal file
21
unity/Assets/2.5D Engine/Scripts/CameraFollow.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace IndianOceanAssets.Engine2_5D
|
||||
{
|
||||
// This class makes the camera follow a target transform with a specified offset.
|
||||
public class CameraFollow : MonoBehaviour
|
||||
{
|
||||
// The target Transform that the camera will follow.
|
||||
[SerializeField] private Transform target;
|
||||
// The positional offset from the target.
|
||||
[SerializeField] private Vector3 offset;
|
||||
|
||||
// Called once per frame.
|
||||
private void Update()
|
||||
{
|
||||
// If a target is assigned, smoothly move the camera towards the target's position plus the offset.
|
||||
if (target)
|
||||
transform.position = Vector3.Lerp(transform.position, target.position + offset, Time.deltaTime * 8f);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
unity/Assets/2.5D Engine/Scripts/CameraFollow.cs.meta
Normal file
11
unity/Assets/2.5D Engine/Scripts/CameraFollow.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: beb5f0bbc354f5d449eea8768c752e72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user