using UnityEngine;
public class Quaternioner : MonoBehaviour
{
// Start is called before the first frame update
public float speed = 3f;
public Transform target;
void Start()
{
}
// Update is called once per frame
void Update()
{
// MoveIt();
//RotaItByLookRotation();
RotaItBySlerp();
}
void MoveIt()
{
//transform.Translate(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0, 0);
transform.Translate( speed * Time.deltaTime, 0, 0);
}
void RotaItByLookRotation()
{
Vector3 relativePos = target.position - transform.position;
transform.rotation = Quaternion.LookRotation(relativePos);
}
void RotaItBySlerp()
{
Vector3 relativePos = (target.position + new Vector3(0, 1.5f, 0)) - transform.position;
Quaternion rotation = Quaternion.LookRotation(relativePos);
Quaterni
unity中四元数的简单示例
最新推荐文章于 2024-01-30 16:12:47 发布