参考:https://www.cnblogs.com/wywnet/p/4790665.html
上面的文章讲的很重要
下面是我自己实现的一个例子
一直一个向量,一个夹角,求另一个向量
按P键改变夹角,Unity开启显示辅助线,可以看见
public Transform Target; float jiaodu = 30f; void LateUpdate() { if (Input.GetKeyDown(KeyCode.P)) { jiaodu += 10f; } Quaternion rotation = Quaternion.Euler(0f, jiaodu, 0f) * Target.rotation; Vector3 newPos = rotation * new Vector3(10f, 0f, 0f); Debug.DrawLine(Target.rotation * new Vector3(10f, 0f, 0f), Vector3.zero, Color.red); Debug.DrawLine(newPos, Vector3.zero, Color.red); Debug.Log("newpos " + newPos + " nowpos " + Target.position + " distance " + Vector3.Distance(newPos, Target.position)); }