30 lines
619 B
C#
30 lines
619 B
C#
using UnityEngine;
|
|
|
|
public class WorldIcon : MonoBehaviour
|
|
{
|
|
[SerializeField] Transform target;
|
|
[SerializeField] float height = 3f;
|
|
|
|
Camera cam;
|
|
|
|
void Start()
|
|
{
|
|
cam = Camera.main;
|
|
}
|
|
|
|
void LateUpdate()
|
|
{
|
|
if (cam == null)
|
|
return;
|
|
|
|
transform.position = target.position + Vector3.up * height;
|
|
|
|
transform.forward = cam.transform.forward;
|
|
|
|
float distance = Vector3.Distance(cam.transform.position, target.position);
|
|
|
|
float scale = Mathf.Clamp(distance * 0.015f, 1f, 2.5f);
|
|
|
|
transform.localScale = Vector3.one * scale;
|
|
}
|
|
} |