コード例 #1
0
        //Debug and checks handling
        private void RecivePathDelegate(Path path)
        {
            if (path.pathType != PathResultType.Valid)
            {
                Debug.LogWarningFormat("path is not valid. reason: {0}", path.pathType);
            }

            ExampleThings.PathToLineRenderer(_line, path, 0.2f);
        }
コード例 #2
0
        void Start()
        {
            //creating agents
            //In normal case you probably want to add PathFinderAgent as normal component
            //But in that case one agent for continuous path requests and other request path just when left click performed and actual movement

            //add agent for actual movement
            _agentForPath            = gameObject.AddComponent <PathFinderAgent>();
            _agentForPath.properties = properties;

            //add agent which used just for showing path
            _agentForDebugPath            = gameObject.AddComponent <PathFinderAgent>();
            _agentForDebugPath.properties = properties;

            _controler = GetComponent <CharacterController>();

            transform.rotation   = Quaternion.Euler(Vector3.zero);
            cameraTargetDistance = cameraDistance;

            //getting gameobjects with lineRenderer
            _linePath    = ExampleThings.GetLineRenderer(pathMaterial, debugWidth);
            _lineDebuger = ExampleThings.GetLineRenderer(debugMaterial, debugWidth);


            //handling of path debug and messages in case something went wrong

            //delegate for normal path
            _agentForPath.SetRecievePathDelegate((Path path) => {
                if (path.pathType != PathResultType.Valid)
                {
                    Debug.LogWarningFormat("path is not valid. reason: {0}", path.pathType);
                }
                ExampleThings.PathToLineRenderer(_linePath, path, 0.3f); //it drawed slightly higher
            }, AgentDelegateMode.ThreadSafe);

            //delegate for path debug
            _agentForDebugPath.SetRecievePathDelegate((Path path) => {
                if (path.pathType != PathResultType.Valid)
                {
                    switch (path.pathType)
                    {
                    case PathResultType.InvalidAgentOutsideNavmesh:
                        Debug.Log("No path. Or navmesh generating where agent are");
                        break;

                    case PathResultType.InvalidTargetOutsideNavmesh:
                        Debug.Log("No path. Or navmesh are generating where your mouse cursor are");
                        break;

                    case PathResultType.InvalidNoPath:
                        Debug.Log("No path. Or navmesh are generating here right now");
                        break;

                    default:
                        Debug.LogWarningFormat("path is not valid. reason: {0}", path.pathType);
                        break;
                    }
                }
                ExampleThings.PathToLineRenderer(_lineDebuger, path, 0.2f);//it drawed slightly lower
            }, AgentDelegateMode.ThreadSafe);

            pointerEventData = new PointerEventData(EventSystem.current);
        }
コード例 #3
0
ファイル: Example4.cs プロジェクト: mgood7123/Bullet-Time
 //simple debug to show path
 private void RecivePathDlegate(Path path, int index)
 {
     ExampleThings.PathToLineRenderer(_lines[index], path, 0.2f);
 }