Unity and Cocos stay as parallel schemes; apps/minigame ships the Godot 4.7 WeChat pack for DevTools. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
814 B
C#
25 lines
814 B
C#
using UnityEngine;
|
|
|
|
namespace Nomadro.Minigame
|
|
{
|
|
public class CameraFollow : MonoBehaviour
|
|
{
|
|
public Transform target;
|
|
public Vector3 offset = new Vector3(0f, 4.2f, -6.5f);
|
|
public float follow = 5f;
|
|
public float lookHeight = 1.1f;
|
|
|
|
void LateUpdate()
|
|
{
|
|
if (target == null) return;
|
|
var back = target.forward;
|
|
back.y = 0f;
|
|
if (back.sqrMagnitude < 0.001f) back = Vector3.forward;
|
|
back.Normalize();
|
|
var desired = target.position - back * Mathf.Abs(offset.z) + Vector3.up * offset.y;
|
|
transform.position = Vector3.Lerp(transform.position, desired, 1f - Mathf.Exp(-follow * Time.deltaTime));
|
|
transform.LookAt(target.position + Vector3.up * lookHeight);
|
|
}
|
|
}
|
|
}
|