Repository URL to install this package:
Version:
1.3.1 ▾
|
using Fluctio.FluctioSim.Common.Configuration;
using Unity.MLAgents.Actuators;
using UnityEngine;
namespace Fluctio.FluctioSim.Core.Components.MachineLearning.Actuating
{
[AddComponentMenu(Config.PrefixedName+"/Machine Learning/Actuating/Change Control", Config.ComponentMenuOrder + 520)]
public class ChangeControl : DirectControl
{
[SerializeField] private float strength = 0.01f;
private float _cumulativeChange = 0f;
public override ActionBuffers GetActions()
{
var modelActionValue = base.GetActions().GetOneContinuous();
var valueChange = modelActionValue * strength; //remap [-1; 1] to [-strength; strength]
_cumulativeChange += valueChange;
return ActionBuffersExtensions.FromOneContinuous(_cumulativeChange);
}
}
}