Esempio n. 1
0
        private void SetupNavVectorField()
        {
            float xCount = width / dist, yCount = height / dist, zCount = length / dist;

            for (int x = 0; x < xCount + 1; x++)
            {
                Vector3 right = startTransform.right * x * dist;
                for (int y = 0; y < yCount + 1; y++)
                {
                    Vector3 up = startTransform.up * y * dist;
                    for (int z = 0; z < zCount + 1; z++)
                    {
                        Vector3 forward = startTransform.forward * z * dist;

                        Vector3 dir = (right + up + forward);

                        VectorNode newNode = ScriptableObject.CreateInstance("VectorNavigation.VectorNode") as VectorNode;
                        newNode.postition = offset;
                        newNode.direction = dir;
                        startNodes.Add(newNode);
                        indexList.Add(newNode.GetRelativPosition());
                    }
                }
            }
        }
Esempio n. 2
0
        public void Setup(VectorNode node, Vector3 start, Vector3 end, VectorPathNode preNode)
        {
            vecNode = node;

            position = node.GetRelativPosition();
            normal   = node.normal;

            if (preNode == null)
            {
                startDistance = Vector3.Distance(position, start);
            }
            else
            {
                startDistance = Vector3.Distance(position, preNode.position) + preNode.startDistance;

                lastNode = preNode;
                name     = preNode.name + 1;
                lastName = name - 1;
            }
            endDistance = Vector3.Distance(position, end);
        }