Unity Timeout Exception when using Heuristic Only

I am trying to train an imitation learning agent. I have entered the Heuristic function in my AI so I can control it. But if I select ‘Heuristic Only’ as behaviour type, the environment crashes after about 50 seconds saying Unity Timeout Exception. Full error message is below. I have Python 3.8.5, Unity 2020.3.0f1. I have tried a different Neural Net. Behaviour Type ‘Default’ works as expected but I can’t train my agent that way. Anyone know how I could get it working again? Thanks.

Also, I’m using Anaconda3 for the virtual environment. A demo file is still created at the end of the run.

(mlagents-r8) E:\Programming\Unity Hub\My projects\Rocket Ball wAI>mlagents-lear
n --time-scale 0.002 --target-frame-rate 60 --run-id P2AIAtt5

(Unity logo)

Version information:
  ml-agents: 0.25.0,
  ml-agents-envs: 0.25.0,
  Communicator API: 1.5.0,
  PyTorch: 1.8.0
2021-03-25 22:56:04 INFO [learn.py:245] run_seed set to 7283
2021-03-25 22:56:04 INFO [torch.py:58] default Torch device: cuda
2021-03-25 22:56:06 INFO [environment.py:210] Listening on port 5004. Start trai
ning by pressing the Play button in the Unity Editor.
2021-03-25 22:56:12 INFO [environment.py:112] Connected to Unity environment wit
h package version 1.9.0-preview and communication version 1.5.0
2021-03-25 22:57:18 INFO [subprocess_env_manager.py:220] UnityEnvironment worker
0: environment stopping.
2021-03-25 22:57:18 INFO [trainer_controller.py:81] Saved Model
Traceback (most recent call last):
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\runpy.py", line 194, in _r
un_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\runpy.py", line 87, in _ru
n_code
    exec(code, run_globals)
  File "E:\Programming\Anaconda3\envs\mlagents-r8\Scripts\mlagents-learn.exe\__m
ain__.py", line 7, in <module>
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\learn.py", line 250, in main
    run_cli(parse_command_line())
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\learn.py", line 246, in run_cli
    run_training(run_seed, options)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\learn.py", line 125, in run_training
    tc.start_learning(env_manager)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents_env
s\timers.py", line 305, in wrapped
    return func(*args, **kwargs)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\trainer_controller.py", line 173, in start_learning
    self._reset_env(env_manager)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents_env
s\timers.py", line 305, in wrapped
    return func(*args, **kwargs)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\trainer_controller.py", line 105, in _reset_env
    env_manager.reset(config=new_config)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\env_manager.py", line 68, in reset
    self.first_step_infos = self._reset_env(config)
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\subprocess_env_manager.py", line 333, in _reset_env
    ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {})
  File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
iners\subprocess_env_manager.py", line 98, in recv
    raise env_exception
mlagents_envs.exception.UnityTimeOutException: The Unity environment took too lo
ng to respond. Make sure that :
         The environment does not need user interaction to launch
         The Agents' Behavior Parameters > Behavior Type is set to "Default"
         The environment and the Python interface have compatible versions.

Ok, so you don’t connect to the port when you’re training an imitation learning agent, you just record the demo file. Egg is on my face.