You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
690 B
C#
22 lines
690 B
C#
1 month ago
|
using UnityEngine;
|
||
|
|
||
|
public class CameraTracker : MonoBehaviour
|
||
|
{
|
||
|
public Transform anchor; // CameraFollowAnchor
|
||
|
public Vector3 offset = new Vector3(5f, 1.5f, 0f); // Side view offset
|
||
|
public float smoothTime = 0.2f;
|
||
|
|
||
|
private Vector3 velocity;
|
||
|
|
||
|
void LateUpdate()
|
||
|
{
|
||
|
if (anchor == null) return;
|
||
|
|
||
|
// Smooth camera movement
|
||
|
Vector3 targetPos = anchor.position + offset;
|
||
|
transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref velocity, smoothTime);
|
||
|
|
||
|
// Look straight toward +X or -X (whichever is side view)
|
||
|
transform.rotation = Quaternion.Euler(0, 90f, 0); // ← adjust based on your orientation
|
||
|
}
|
||
|
}
|