EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

[Unity]什么是Vector3.ProjectOnPlane?

什么是Vector3.ProjectOnPlane?

 

官方文档解释得可能太长了,

public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)

一共2个参数,vector是你的向量,planeNormal某个平面的法向量。

 

这个函数返回的是vector某个平面的投影向量。

 

实现方式如下:

Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)
{
    return vector - planeNormal * Vector3.Dot(vector, planeNormal.normalized);
}

 

回到目录:

[1] [Unity]从零开始认识C#脚本——以第三人称控制器为例

 

参考文档:

[1] https://docs.unity3d.com/ScriptReference/Vector3.ProjectOnPlane.html

[2] https://answers.unity.com/questions/1601159/i-dont-understand-vector3projectonplane.html

[3] https://blog.csdn.net/kenight/article/details/90080683

This article was last edited at 2020-04-06 17:49:43

* *