Ejemplo n.º 1
0
        /// <summary>
        /// Moves the agent to a position in the <see cref="AgentYfb.m_CurrentNode" />
        /// </summary>
        public virtual void MoveToNode()
        {
            Vector3 nodePosition = m_CurrentNode.GetRandomPointInNodeArea();

            nodePosition.y = m_CurrentNode.transform.position.y;
            m_Destination  = nodePosition;
            NavigateTo(m_Destination);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Spawns the agent
        /// </summary>
        /// <param name="agentConfig">The agent to spawn</param>
        /// <param name="node">The starting node that the agent uses</param>
        protected virtual void SpawnAgent(AgentConfigurationYfb agentConfig, NodeYfb node)
        {
            Vector3 spawnPosition = node.GetRandomPointInNodeArea();

            var poolable = Poolable.TryGetPoolable <Poolable>(agentConfig.agentPrefab.gameObject);

            if (poolable == null)
            {
                return;
            }
            var agentInstance = poolable.GetComponent <AgentYfb>();

            agentInstance.transform.position = spawnPosition;
            agentInstance.Initialize();
            agentInstance.SetNode(node);
            agentInstance.transform.rotation = node.transform.rotation;
        }