using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UserC : MonoBehaviour
{
//主摄像机对象
private new Camera camera;
void Start()
{
camera = Camera.main;
}
private void Update()
{
// 物体始终面向摄像机
var rotation = Quaternion.LookRotation(camera.transform.TransformVector(Vector3.forward),
camera.transform.TransformVector(Vector3.up));
rotation = new Quaternion(0, rotation.y, 0, rotation.w);
gameObject.transform.rotation = rotation;
}
}
相关文章
- 09-30Unity人员始终面对摄像机
- 09-30Unity3D c# 使对象物体始终面向摄像机