csharp LookAt和Fixed LookAt

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp LookAt和Fixed LookAt相关的知识,希望对你有一定的参考价值。

using UnityEngine;
using System.Collections;

public class LookAtFixed : MonoBehaviour {
	public Transform lookAt;
	
	void Update()
	{
		Vector3 worldLookDirection = lookAt.position - transform.position;
		Vector3 localLookDirection = transform.InverseTransformDirection(worldLookDirection);
		localLookDirection.y = 0;
		transform.forward = transform.rotation * localLookDirection;
	}
}
using UnityEngine;
using System.Collections;

public class LookAt : MonoBehaviour {
	public Transform lookAt;

	void Update() {
		transform.LookAt(lookAt);
	}
}

以上是关于csharp LookAt和Fixed LookAt的主要内容,如果未能解决你的问题,请参考以下文章

在 three.js 中移动相机、lookAt 和旋转

Java中正则Matcher类的matches,lookAt和find的区别

#yyds干货盘点#three.js中相机的lookAt和control的target区别

LookAt (glm) 返回错误的平移 z 值

UE4中程序驱动的LookAt动画

如何使用 glm::lookAt() 旋转对象?