<スクリプト>
using System.Collections; using System.Collections.Generic; using UnityEngine; public class SlowLookAt : MonoBehaviour { public GameObject target; private float distance; public float speed; private float step; void Update() { // 2点間の距離を計測 distance = Vector3.Distance(transform.position, target.transform.position); // 一定の範囲内に入ったら実行 if(distance < 5f) { step = speed * Time.deltaTime; Vector3 targetDir = target.transform.position - transform.position; Vector3 moveDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0f); transform.rotation = Quaternion.LookRotation(moveDir); } } }