Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Manually switch behavior type

Discussion in 'ML-Agents' started by mmmbop, Aug 18, 2022.

  1. mmmbop

    mmmbop

    Joined:
    Jan 22, 2022
    Posts:
    20
    I need change behavior type of my Agent when episode is end. Because my agent have rigibodies and relies on physics, resetting position with failing cause bad results when i agent trying to reset at start position, because at this time he tries to move ( he got NN attached).
    So it is possible to change with code BehaviorType of my Agent to heuristic and back to NN?
    I found that this not working
    Code (CSharp):
    1. GetComponent<Unity.MLAgents.Policies.BehaviorParameters>().BehaviorType=1
    and this didnt find component "Behavior parameter":
    Code (CSharp):
    1. GetComponent<BehaviorParameters>().BehaviorType = 1;
    How to access it manually? I need to turn off NN, replace my agent without any rigidbody/physics troubles and turn NN on again.
     
  2. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    130
    you can make the rigidbody kinematic, move it, then switch it back to dynamic