First project upload
This commit is contained in:
32
Assets/New Lowpoly Models/Scripts/MinimapCameraFollow.cs
Normal file
32
Assets/New Lowpoly Models/Scripts/MinimapCameraFollow.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user