22 lines
551 B
C#
22 lines
551 B
C#
![]() |
using UnityEngine;
|
||
|
|
||
|
public class SimpleFollower : MonoBehaviour
|
||
|
{
|
||
|
[Header("Follow Settings")]
|
||
|
public Transform target; // The transform to follow
|
||
|
public float followSpeed = 5f; // Higher = snappier movement
|
||
|
public Vector3 offset; // Optional offset from target
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
if (target == null) return;
|
||
|
|
||
|
// Smooth follow
|
||
|
transform.position = Vector3.Lerp(
|
||
|
transform.position,
|
||
|
target.position + offset,
|
||
|
followSpeed * Time.deltaTime
|
||
|
);
|
||
|
}
|
||
|
}
|