docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method CollectObservations

    CollectObservations(VectorSensor)

    Implement CollectObservations() to collect the vector observations of the agent for the step. The agent observation describes the current environment from the perspective of the agent.

    Declaration
    public virtual void CollectObservations(VectorSensor sensor)
    Parameters
    Type Name Description
    VectorSensor sensor

    The vector observations for the agent.

    Remarks

    An agent's observation is any environment information that helps the agent achieve its goal. For example, for a fighting agent, its observation could include distances to friends or enemies, or the current level of ammunition at its disposal.

    You can use a combination of vector, visual, and raycast observations for an agent. If you only use visual or raycast observations, you do not need to implement a CollectObservations() function.

    Add vector observations to the sensor parameter passed to this method by calling the VectorSensor helper methods: - AddObservation(int) - AddObservation(float) - AddObservation(Vector3) - AddObservation(Vector2) - AddObservation(Quaternion) - AddObservation(bool) - AddObservation(IList<float>) - AddOneHotObservation(int, int)

    You can use any combination of these helper functions to build the agent's vector of observations. You must build the vector in the same order each time CollectObservations() is called and the length of the vector must always be the same. In addition, the length of the observation must match the VectorObservationSize attribute of the linked Brain, which is set in the Editor on the Behavior Parameters component attached to the agent's GameObject.

    For more information about observations, see Observations and Sensors.

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023