【发布时间】:2017-06-13 13:43:35
【问题描述】:
我是 Unity 的初学者,我想独自创建一个个人项目。 我在场景中有两个游戏对象,我在 Unity 上使用 LineRenderer 和 NavMesh 代理在两个游戏对象之间绘制路径,到目前为止,一切都很好,Unity 在两个游戏对象之间绘制路径。
Void Update (){
OnDrawGiz(GameObject.Find("Destination"));
}
void OnDrawGiz(GameObject obj)
{
Transform target = obj.GetComponent<Transform> ();
NavMeshAgent nav;
LineRenderer line;
nav= this.GetComponent<NavMeshAgent>();
if( nav == null || nav.path == null )
return;
line = this.GetComponent<LineRenderer>();
line.material = new Material( Shader.Find( "Sprites/Default" ) ) { color
= Color.yellow };
line.startColor=Color.yellow;
line.endColor = Color.green;
nav.SetDestination (target.position);
nav.isStopped=true;
var path = nav.path;
if (path.corners.Length < 2)
return ;
line.positionCount=path.corners.Length ;
//Draw the line
for( int i = 0; i < path.corners.Length; i++ )
{
line.SetPosition( i, path.corners[i] );
}
}
darw path 现在我的问题是如何放置和复制游戏对象,例如沿着这条路径或穿过这条路径的立方体? Here photo the result which i want to have
我使用 C# 脚本,Unity 5.6
【问题讨论】:
标签: c# unity3d navigation