Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Can I have multiple Vector Sensors?

Discussion in 'ML-Agents' started by hyerra, Jul 23, 2023.

  1. hyerra


    Jan 24, 2023
    I want to use multiple Vector Sensors for my observations, due to different requirements in stacking and just better separation overall. However, I'm having some trouble doing so.

    First, I added an additional VectorSensorComponent to my agent in the editor. Then, in my Agent script, I run GetComponent<VectorSensorComponent>() and set it to `_vectorSensorComponent` to get the vector sensor component which works well. Then, whenever I receive some game related events that require updating the vector sensor, I try doing `_vectorSensorComponent.GetSensor().AddObservation(someObservation)`. All of this code runs fine; however, in the logs I notice that MLAgents is complaining that there were 0 observations recorded for this sensor even though I am sure the code to add observations is getting called (verified using Debug.Log).

    I was wondering if having multiple VectorSensors is supported, and if so, how to go about doing this.
  2. kezzyhko


    Jun 15, 2019
    I'm having the same issue. Looks like VectorSensor clears all observations in Update before actually using them