Hi people, I need help with building an efficient method to make car control work in a racing game, both for the player and for the AI.
Before wanting to implement ML-Agents, I have been using a class that stores the variables for each command, together with two subclasses that differentiate the player’s inputs from those of the AI, through inheritance.
public class MasterInput : MonoBehaviour
{
protected float accel;
protected float brake;
protected float steer;
protected bool boost;
//stuff
}
public class PlayerInput : MasterInput
{
//functional stuff with New Input System
}
public class MachineInput : MasterInput
{
//functional stuff with AI-related script
}
Which are used to control the vehicle, regardless of who is controlling it. It even executes specific commands depending on the script loaded in the GameObject.
public class CarMovement : MonoBehaviour
{
//car variables
MasterInput mInput;
void Start()
{
mInput = GetComponent<MasterInput>();
if (mInput is PlayerInput)
{
// do specific thing
}
else if (mInput is MachineInput)
{
// do specific thing
}
}
//stuff
}
However, when I have wanted to integrate with ML-Agents, I get the error CS1721.
public class MachineInput : Agent, MasterInput
{
//stuff failed to work
}
I would like to know how this can be solved, if possible.