void FixedUpdate() { if (transform.position.x > SimulationCtrl.Instance.bounds.x) { transform.position = new Vector3(-SimulationCtrl.Instance.bounds.x, 1, transform.position.z); } if (transform.position.x < -SimulationCtrl.Instance.bounds.x) { transform.position = new Vector3(SimulationCtrl.Instance.bounds.x, 1, transform.position.z); } if (transform.position.z > SimulationCtrl.Instance.bounds.y) { transform.position = new Vector3(transform.position.x, 1, -SimulationCtrl.Instance.bounds.y); } if (transform.position.z < -SimulationCtrl.Instance.bounds.y) { transform.position = new Vector3(transform.position.x, 1, SimulationCtrl.Instance.bounds.y); } RaycastHit hit; if (Physics.Raycast(transform.position, Vector3.down, out hit, 10f, groundLayer)) { groundNormal = hit.normal; } moveManager.ResetManager(); moveManager.Flock(); //moveManager.Separate(); //moveManager.Align(); //moveManager.Cohere(); RaycastHit mousePoint; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out mousePoint, 100f, groundLayer)) { moveManager.Seek(mousePoint.point); } rb.AddForce(moveManager.Steering, ForceMode.VelocityChange); }