示例
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraLookAt : MonoBehaviour
{
public bool lookAt = true;
public Transform target;
private Transform mTransform;
void Awake()
{
mTransform = transform;
}
void Update()
{
if (target == null)
return;
if (lookAt)
mTransform.LookAt(target, Vector3.up);
}
}