[Unity]Debug.DrawLine()是什么?如何使用?
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/231
Debug.DrawLine()是在场景视图中可视化地面检查光线的工具。
Debug.DrawLine()方法有2个参数,
DrawLine(起始坐标,结束坐标)
关于Unity官方插件中的ThirdPersonCharacter.cs中的这一句:
Debug.DrawLine(transform.position + (Vector3.up * 0.1f), transform.position + (Vector3.up * 0.1f) + (Vector3.down * m_GroundCheckDistance));
在Scene中的实际效果是这样的:
注释掉这段代码,是这样的:
然后我们来分析这段代码,
第一个参数——transform.position + (Vector3.up * 0.1f)
第二个参数——transform.position + (Vector3.up * 0.1f) + (Vector3.down * m_GroundCheckDistance)
第一个参数——(0,0,0)+(0,1,0)*0.1f
第二个参数——(0,0,0)+(0,1,0)*0.1f+(0,-1,0)*0.1f
不理解Vector3.up为什么是(0,1,0)点击→这里。
参考文档:
[1] Unity Documentation-Scripting API : Debug.DrawLine
This article was last edited at 2020-04-04 18:32:40