// Update is called once per frame // Using Fixed update because it's easy to speed up. When in real time, should probably split decision making into Update() from action activation in FixedUpdate() void FixedUpdate() { if (!m_is_initialized) { Debug.LogError("Creatures require initilization after Instantiation"); } //Tick Event Managers m_tm.tick(Time.fixedDeltaTime); m_im.tick(Time.fixedDeltaTime); //Set forward to correct forward vector m_forward = Vector2Calc.fromAngle(gameObject.transform.rotation.eulerAngles.z + 90); //Actiavte and flush the actions priority list m_actions.activate(); }
// Using Fixed update because it's easy to speed up. When in real time, should probably split decision making into Update() from action activation in FixedUpdate() void FixedUpdate() { if (!m_is_initialized) { Debug.LogError("Creatures require initilization after Instantiation"); } //Tick the timeout event manager m_tm.tick(Time.fixedDeltaTime); m_im.tick(Time.fixedDeltaTime); m_cooldowns.tickAll(Time.fixedDeltaTime); //Set forward to correct forward vector m_forward = Vector2Calc.fromAngle(gameObject.transform.rotation.eulerAngles.z + 90); if (!m_brain_stop) { if (m_decision_time) { m_actions.flush(); //Call fixed update of Controller to do one brain iteration setBehaviours(); m_decision_time = false; } //Actiavte and flush the actions priority list m_actions.activate(); } //Update fitness for this frame m_fitness += fitnessUpdate(); energyConsumer(Time.fixedDeltaTime * 0.2f); consumeMoveEnergy(Time.fixedDeltaTime); if (m_energy.isMin()) { m_renderer.color = Color.red; } else { m_renderer.color = Color.green; } }