Example #1
0
        void Awake()
        {
            if (smoothing)
            {
                // If smoother attached then use that.
                m_Smoother = GetComponent <Smoother> ();

                // Else add smoother componenet.
                if (!m_Smoother)
                {
                    m_Smoother = gameObject.AddComponent <Smoother> ();
                }
            }

            if (AGENT_DB == null)
            {
                AGENT_DB = FindObjectOfType <AgentDatabase> ();
            }
        }
Example #2
0
        /// <summary>
        /// Gets behaviour manager and smoother (if smoothing is enabled) and sets heading to an arbitrary position.
        /// </summary>
        void Start()
        {
            behaviourManager = GetComponent <BehaviourManager> ();

            velocity = Vector2.zero;

            float rotation = Random.Range(0f, 2f) * (Mathf.PI * 2);

            heading = new Vector2((float)Mathf.Sin(rotation), (float)-Mathf.Cos(rotation));

            if (smoothing)
            {
                // If smoother attached then use that.
                smoother = GetComponent <Smoother> ();

                // Else add smoother componenet.
                if (!smoother)
                {
                    smoother = gameObject.AddComponent <Smoother> ();
                }
            }
        }