HI! I'm doing this little 3D project to understand how ML-Agents works and then expand it and make a nice training environment.
However, I am having some problems with the coding and settings of Unity.
This is the code:
` private void Jump()
{
//Button was just pushed
if (Input.GetKeyDown(KeyCode.Space) && OnGround)
{
isJumping = true;
JumpTimeCounter = JumpTime;
CubeRigidbody.velocity = new Vector3(CubeRigidbody.velocity.z, JumpForce);
Debug.Log("Spazio premuto");
OnGround = false;
}
//Button is being held
if (Input.GetKey(KeyCode.Space))
{
if (JumpTimeCounter > 0 && isJumping)
{
CubeRigidbody.velocity = new Vector3(CubeRigidbody.velocity.z, JumpForce);
Debug.Log("Spazio mantenuto");
JumpTimeCounter -= Time.deltaTime;
}
else
{
isJumping = false;
}
}
//Button war releared
if (Input.GetKeyUp(KeyCode.Space))
{
isJumping = false;
Debug.Log("Spazio rilasciato");
}
}`
I want to create a system with ML-Agent that do this same thing (hold Jump super mario like)