/** * If the base is hit (collided with), drop resources and change back to * random walk state. */ void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "AntHill") { _resourceManager.AddResources(inventory.carryCount); inventory.Clear(); // Make agent rotate 180 degrees. if (state.IsReturningToBase()) { navHelper.SetDirection(-navHelper.GetDirection()); transform.rotation = transform.rotation * Quaternion.AngleAxis(180f, transform.up); } state.currentState = EAntStates.Idle; } }