如何把一个向量按对应的轴 旋转x度
如图所示 旋转了90度:
代码如下:
public Vector3 dir = new Vector3(0, 0, 1f);
void Update()
{
Vector3 newDir = Quaternion.AngleAxis(90, Vector3.up) * dir;
Debug.DrawLine(transform.position, transform.position + dir * 10, Color.red);
Debug.DrawLine(transform.position, transform.position + newDir * 10);
transform.position += newDir * Time.deltaTime;
}
网友评论