In the ML-Agent tutorial, there was a problem that could not be solved by following the document, so I would like to ask you a question.
I've looked through other questioning sites, but I can't help it... I'd like to use your help.
Here are the codes and errors.
using System.Collections.General;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Sensors;
using Unity.MLAgents.Actuators;
public class RollerAgent:Agent
{
RigidbodyrBody;
void Start() {
rBody = GetComponent <Rigidbody >();
}
public Transform Target;
public override void OnEpisodeBegin()
{
// If the Agent fell, zeroits moment
if (this.transform.localPosition.y<0)
{
This.rBody.angularVelocity=Vector3.zero;
this.rBody.velocity=Vector3.zero;
this.transform.localPosition=new Vector3(0,0.5f,0);
}
// Move the target to a new spot
Target.localPosition = new Vector3 (Random.value*8-4,
0.5f,
Random.value*8-4);
}
public override void CollectObserutions (VectorSensor sensor)
{
// Target and Agent positions
sensor.AddObserveration(Target.localPosition);
sensor.AddObserveration(this.transform.localPosition);
// Agent velocity
sensor.AddObserveration(rBody.velocity.x);
sensor.AddObserveration(rBody.velocity.z);
}
public float forceMultiplier=10;
public override void OnActionReceived (ActionBuffers actionBuffers)
{
// Actions, size = 2
Vector3 controlSignal=Vector3.zero;
controlSignal.x = actionBuffers.ContinuousActions[0];
controlSignal.z=actionBuffers.ContinuousActions[1];
rBody.AddForce(controlSignal*forceMultiplier);
// Rewards
float distanceToTarget=Vector3.Distance(this.transform.localPosition, Target.localPosition);
// Reached target
if (distanceToTarget<1.42f)
{
SetReward (1.0f);
EndEpisode();
}
// Fell off platform
else if (this.transform.localPosition.y<0)
{
EndEpisode();
}
}
public override void Heuristic (in ActionBuffers actionsOut)
{
var continuousActionsOut=actionsOut.ContinuousActions;
continuousActionsOut[0] = Input.GetAxis("Horizontal");
continuousActionsOut[1] = Input.GetAxis("Vertical");
}
}
The error (warning) appears continuously when you press the Play button, and although the document says you can use the cross key to manipulate the Agent, it does not work.
OS: macOS Venture 13.1
ML-Agent:Release 20
documentation:
https://github.com/Unity-Technologies/ml-agents/blob/develop/docs/Learning-Environment-Create-New.md
Thank you for your cooperation.
c# unity3d
Self-resolved.
"I was told on another site that ""detaching the Agent (Script) will cure it"", so I tried it, and found out that
"InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input Handling to Input System package in Player Settings.
The error is
However, I was told that changing the settings would cure it, so
Change the Edit->ProjectSettings->Player->Active Input Handling check box to both
Then there will be no errors, and you will be able to operate them yourself!
Incidentally, the error Fewer observations(0)made...
was also resolved at the same time.
Sorry for the trouble.
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
578 Understanding How to Configure Google API Key
581 PHP ssh2_scp_send fails to send files as intended
911 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.