Example #1
0
        private void OnDrawGizmos()
        {
            Gizmos.color = Color.cyan;

            WavePathNode[] nodes        = transform.GetComponentsInChildren <WavePathNode>();
            WavePathNode   previousNode = null;

            foreach (WavePathNode node in nodes)
            {
                Gizmos.DrawSphere(node.transform.position, 0.2f);
                if (previousNode != null)
                {
                    Gizmos.DrawLine(node.transform.position, previousNode.transform.position);
                }
                previousNode = node;
            }
        }
Example #2
0
        void HandleMovement()
        {
            if (currentNode == null || Vector3.Distance(transform.position, currentNode.transform.position) <= DISTANCE_TOLERANCE)
            {
                currentNodeIndex++;
                currentNode = wave.GetPathNode(currentNodeIndex);

                // Reached end
                if (currentNode == null)
                {
                    wave.RemoveEnemy(gameObject);
                    Destroy(gameObject);
                    return;
                }

                Vector3 direction = currentNode.transform.position - transform.position;
                direction.Normalize();
                mover.SetDirection(direction, currentNode.SpeedFractionToThisNode);
            }
        }