一旦播放器单击任何位置,我如何绘制曲线 直线以显示可能的路径



我正在尝试制作演员是船只的基于回合的游戏。因此,将更改其位置的运动将需要vector3.for3.forward和vector3.Rotation。

我得到了使它实际移动已经工作的代码,我能够使用linerenderer和debug.drawline生成/创建路径。

但是,我似乎找不到任何资源来绘制节点/行在播放器实际移动之前显示路径。

以下是我要模拟的代码的示例。

void Update () {
    if (this.isMoving){
        if(Vector3.Distance(walkDestination, transform.position) > 0.2f){
            float step = 0f;
            step = this.speed * Time.deltaTime;
            transform.position = Vector3.MoveTowards(transform.position, walkDestination, step);
            Vector3 rotationDestination = this.rotateDestination;
            Quaternion targetRotation = Quaternion.LookRotation(rotationDestination - transform.position, Vector3.up);
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 6.0f);
        }else{
            //Arrived to destination
        }
    }
}

大多数资源(如果不是全部(都指出了NavMesh或Grid System,这些系统与我的系统不符,因为我允许在Quad上不受限制地移动。

我很感激是否有人可以将我指向正确的方向,以在设备实际移动之前从A点到B点绘制可能的路径。

这听起来像是Unity的行渲染器组件的工作:

  • 手册
  • 视频教程
  • 论坛发布

hth。

最新更新