Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Resolved How to stop agent from automatically respawning?

Discussion in 'ML-Agents' started by snuwman, Apr 8, 2021.

  1. snuwman

    snuwman

    Joined:
    Jul 6, 2020
    Posts:
    2
    Basically I have a project setup similar to the Unity's "Pyramid" example. The thing is that in my game agents respawn with a delay: agent dies -> 10 seconds not present in game -> spawns at random coordinates. I tried finding a way to prevent Academy from calling OnEpisodeBegin() before the 10 seconds have passed, but didn't find a way. I also tried googling, but didn't find anything. Could someone explain, how exactly does the whole Academy cycle thing work and how to control/override it?

    Many thanks.
     
  2. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    335
    I'm assuming you're using a DecisionRequester component on your agent? The component requests decisions and actions automatically, based on Academy steps. When it keeps requesting decisions after an episode has ended, OnEpisodeBegin() is invoked again right away.

    AFAIK, you can work around this in one of the following ways:
    1) Destroy the DecisionRequester component when the episode ends and re-add one when your respawn logic is complete.
    2) Extend https://github.com/Unity-Technologi....unity.ml-agents/Runtime/DecisionRequester.cs and override ShouldRequestDecision() in order to enable/disable requests to fit your needs.
    3) Write your own decision requester code and disable automatic stepping altogether, see https://forum.unity.com/threads/brain-update-control.1043317/
     
    Last edited: Apr 9, 2021
    snuwman likes this.
  3. snuwman

    snuwman

    Joined:
    Jul 6, 2020
    Posts:
    2
    Thanks! That's exactly what I was looking for.
     
unityunity