[Unity]什么是Vector3.ProjectOnPlane?
Copyright Notice: This article is an original work licensed under the CC 4.0 BY-NC-ND license.
If you wish to repost this article, please include the original source link and this copyright notice.
Source link: https://v2know.com/article/235
什么是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 08:49:43