Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved The type or namespace name 'ActionBuffers' could not be found

Discussion in 'ML-Agents' started by ArthurHaleta, Apr 2, 2022.

  1. ArthurHaleta

    ArthurHaleta

    Joined:
    Dec 24, 2021
    Posts:
    44
    I was following a tutorial on youtube on setting up MLAgents in my game. Everything worked fine until the line OnActionReceived(ActionBuffers actions). Here is the code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Unity.MLAgents;
    5. using Unity.MLAgents.Sensors;
    6.  
    7. public class agentLearn : Agent
    8. {
    9.     public override void CollectObservations(VectorSensor sensor)
    10.     {
    11.         sensor.AddObservation(GetComponent<Renderer>().material.color.r);
    12.         sensor.AddObservation(GetComponent<Renderer>().material.color.g);
    13.         sensor.AddObservation(GetComponent<Renderer>().material.color.b);
    14.     }
    15.  
    16.     public override void OnActionReceived(ActionBuffers actions)
    17.     {
    18.         float r = actions.ContinuousActions[0];
    19.         float g = actions.ContinuousActions[1];
    20.         float b = actions.ContinuousActions[2];
    21.  
    22.         GetComponent<Renderer>().material.color = new Color(r, g, b);
    23.     }
    24. }
    Im using MLAgents package version 2.3.0-exp.2 - March 30, 2022, Unity version 2020.3.
     
    PlusheeStudios likes this.
  2. ArthurHaleta

    ArthurHaleta

    Joined:
    Dec 24, 2021
    Posts:
    44
    I made a very dumb mistake. I was supposed to add 'Unity.MLAgents.Actuators' at the top.I spent like half an hour on that too.
     
  3. stevens68

    stevens68

    Joined:
    Apr 2, 2022
    Posts:
    1
    ...you saved my day ArthurHaleta! Thanks, I did the same mistake like you.
    .