コード例 #1
0
        void SetPathPoint()
        {
            var input = GetSubsystem <Input>();

            Vector3        hitPos;
            Drawable       hitDrawable;
            NavigationMesh navMesh = scene.GetComponent <NavigationMesh>();

            if (Raycast(250.0f, out hitPos, out hitDrawable))
            {
                Vector3 pathPos = navMesh.FindNearestPoint(hitPos, new Vector3(1.0f, 1.0f, 1.0f));

                if (input.GetQualifierDown(Constants.QUAL_SHIFT))
                {
                    // Teleport
                    currentPath.Clear();
                    jackNode.LookAt(new Vector3(pathPos.X, jackNode.Position.Y, pathPos.Z), Vector3.UnitY, TransformSpace.TS_WORLD);
                    jackNode.Position = (pathPos);
                }
                else
                {
                    // Calculate path from Jack's current position to the end point
                    endPos = pathPos;
                    var result = navMesh.FindPath(currentPath, jackNode.Position, endPos);
                }
            }
        }
コード例 #2
0
        void SetPathPoint()
        {
            Vector3        hitPos;
            Drawable       hitDrawable;
            NavigationMesh navMesh = scene.GetComponent <NavigationMesh>();

            if (Raycast(250.0f, out hitPos, out hitDrawable))
            {
                Vector3 pathPos = navMesh.FindNearestPoint(hitPos, new Vector3(1.0f, 1.0f, 1.0f));

                const int qualShift = 1;
                if (Input.GetQualifierDown(qualShift))
                {
                    // Teleport
                    currentPath.Clear();
                    jackNode.LookAt(new Vector3(pathPos.X, jackNode.Position.Y, pathPos.Z), Vector3.UnitY, TransformSpace.World);
                    jackNode.Position = (pathPos);
                }
                else
                {
                    // Calculate path from Jack's current position to the end point
                    endPos = pathPos;
                    var result = navMesh.FindPath(jackNode.Position, endPos);
                    currentPath = new List <Vector3>(result);
                }
            }
        }