예제 #1
0
    private void CalculateMoveCost()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 100f))
        {
            NavMesh.CalculatePath(m_controlledUnit.transform.position, hit.point, NavMesh.AllAreas, path);
        }

        float pathLength = 0;

        for (int i = 1; i < path.corners.Length; i++)
        {
            pathLength += (path.corners[i - 1] - path.corners[i]).magnitude;
            //Debug.DrawLine(path.corners[i - 1], path.corners[i], Color.cyan);
        }
        DebugCanvas.Display(((int)pathLength).ToString());
    }