32 lines
731 B
C#
32 lines
731 B
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class MinimapCameraFollow : MonoBehaviour
|
|
{
|
|
private Transform target;
|
|
public float height = 20f;
|
|
|
|
void LateUpdate()
|
|
{
|
|
FindActivePlayer();
|
|
|
|
if (target == null) return;
|
|
|
|
transform.position = new Vector3(target.position.x, height, target.position.z);
|
|
transform.rotation = Quaternion.Euler(90f, 0f, 0f);
|
|
}
|
|
|
|
void FindActivePlayer()
|
|
{
|
|
var inputs = FindObjectsOfType<PlayerInput>();
|
|
|
|
foreach (var input in inputs)
|
|
{
|
|
if (input.enabled && input.gameObject.activeInHierarchy)
|
|
{
|
|
target = input.transform;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} |