Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question BounceAgent.OnActionReceived(float[])': no suitable method found to override

Discussion in 'ML-Agents' started by SneakySasquatch_, Oct 27, 2022.

  1. SneakySasquatch_

    SneakySasquatch_

    Joined:
    Sep 1, 2022
    Posts:
    2
    Hello everyone!

    Versions:
    ml-agents (python package): 0.28.0
    ml-agents-envs (python package): 0.28.0
    Unity Package Manager package: ML Agents 2.01
    ======================================
    Errors #1:
    Assets\Scripts\BounceAgent.cs(30,25): error CS0115: 'BounceAgent.OnActionReceived(float[])': no suitable method found to override

    &

    Assets\Scripts\BounceAgent.cs(49,25): error CS0115: 'BounceAgent.Heuristic(float[])': no suitable method found to override
    =========================================================================================
    I understand that this code is deprecated - but when I change it to OnActionReceived(ActionBuffers actions) or Heuristic(in ActionBuffers actionsOut), I get the following error:

    Error CS0021 Cannot apply indexing with [] to an expression of type 'ActionBuffers'

    This is because I have not declared an array - but when I do declare an array, I get the following errors:

    Error CS1503 Argument 1: cannot convert from 'Unity.MLAgents.Actuators.ActionBuffers' to 'float'

    &

    Error CS0029 Cannot implicitly convert type 'Unity.MLAgents.Actuators.ActionBuffers' to 'float'

    &

    Error CS0019 Operator '*' cannot be applied to operands of type 'ActionBuffers' and 'ActionBuffers'

    I don't know how to change ActionBuffers to a float...(or if that would help)...

    I tried downgrading my packages, but after 3 days I ended up getting everything back, so I'm not going to use that option. Here is a screenshot of the problematic code...




    Any help would be much appreciated!
     
  2. arthanant47

    arthanant47

    Joined:
    Jul 26, 2021
    Posts:
    2
    Hey I had the same problem and what I did to solve it was use this
    public override void OnActionReceived(ActionBuffers actions)
    {
    if (Mathf.FloorToInt(actions.ContinuousActions[0]) == 1)
    {
    Jump();
    }
    }
    I think this is a little incorrect or inefficient as now ActionBuffers also support DiscreteActions, but this is what I did.
     
  3. lycettthomas94

    lycettthomas94

    Joined:
    Jun 13, 2020
    Posts:
    5
    you need to do:

    var continuousActions = actionBuffers.ContinuousActions;