c# – OnActionReceived not being called
I am trying to override this function. But I don’t think that the function is getting called and it doesn’t give me any error.
public override void OnActionReceived(ActionBuffers actions)
{
// Get the acceleration, brake, and steer actions from the ML-Agents system
float acceleration = actions.ContinuousActions[0];
float brake = Mathf.Clamp(actions.ContinuousActions[1], 0, 1);
float steer = actions.ContinuousActions[2];
Debug.Log(acceleration);
nowAcceleration = motorMax * acceleration;
nowBrake = brakeMax * brake;
nowSteer = steerMax * steer;
// Apply the actions to the car
wheelBackLeft.motorTorque = nowAcceleration;
wheelBackRight.motorTorque = nowAcceleration;
wheelBackLeft.brakeTorque = nowBrake;
wheelBackRight.brakeTorque = nowBrake;
// wheelFrontLeft.brakeTorque = nowBrake;
// wheelFrontRight.brakeTorque = nowBrake;
wheelFrontLeft.steerAngle = nowSteer;
wheelFrontRight.steerAngle = nowSteer;
updateWheel(wheelFrontLeft, frontLeftTransform);
updateWheel(wheelFrontRight, frontRightTransform);
updateWheel(wheelBackLeft, backLeftTransform);
updateWheel(wheelBackRight, backRightTransform);
}
I wanted the car to move and to see my acceleration in the unity console but the car does nothing and nothing is printed in the console.
I’ll appreciate any help.
Thanks
Read more here: Source link