|
|
|
|
|
|
m_ResetParams = Academy.Instance.EnvironmentParameters; |
|
|
|
} |
|
|
|
|
|
|
|
public void MoveAgent(ActionSegment<int> act) |
|
|
|
public void MoveAgent(ActionSegment<float> act) |
|
|
|
{ |
|
|
|
var dirToGo = Vector3.zero; |
|
|
|
var rotateDir = Vector3.zero; |
|
|
|
|
|
|
var forwardAxis = act[0]; |
|
|
|
var rightAxis = act[1]; |
|
|
|
var rotateAxis = act[2]; |
|
|
|
switch (forwardAxis) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
dirToGo = transform.forward * m_ForwardSpeed; |
|
|
|
m_KickPower = 1f; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
dirToGo = transform.forward * -m_ForwardSpeed; |
|
|
|
break; |
|
|
|
} |
|
|
|
var forward = Mathf.Clamp(act[0], -1f, 1f); |
|
|
|
var right = Mathf.Clamp(act[1], -1f, 1f); |
|
|
|
var rotate = Mathf.Clamp(act[2], -1f, 1f); |
|
|
|
switch (rightAxis) |
|
|
|
dirToGo = transform.forward * forward * m_ForwardSpeed; |
|
|
|
dirToGo += transform.right * right * m_LateralSpeed; |
|
|
|
rotateDir = -transform.up * rotate; |
|
|
|
if (forward > 0) |
|
|
|
case 1: |
|
|
|
dirToGo = transform.right * m_LateralSpeed; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
dirToGo = transform.right * -m_LateralSpeed; |
|
|
|
break; |
|
|
|
m_KickPower = forward; |
|
|
|
switch (rotateAxis) |
|
|
|
{ |
|
|
|
case 1: |
|
|
|
rotateDir = transform.up * -1f; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
rotateDir = transform.up * 1f; |
|
|
|
break; |
|
|
|
} |
|
|
|
//m_KickPower = 0f;
|
|
|
|
//var forwardAxis = act[0];
|
|
|
|
//var rightAxis = act[1];
|
|
|
|
//var rotateAxis = act[2];
|
|
|
|
|
|
|
|
//switch (forwardAxis)
|
|
|
|
//{
|
|
|
|
// case 1:
|
|
|
|
// dirToGo = transform.forward * m_ForwardSpeed;
|
|
|
|
// m_KickPower = 1f;
|
|
|
|
// break;
|
|
|
|
// case 2:
|
|
|
|
// dirToGo = transform.forward * -m_ForwardSpeed;
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//switch (rightAxis)
|
|
|
|
//{
|
|
|
|
// case 1:
|
|
|
|
// dirToGo = transform.right * m_LateralSpeed;
|
|
|
|
// break;
|
|
|
|
// case 2:
|
|
|
|
// dirToGo = transform.right * -m_LateralSpeed;
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//switch (rotateAxis)
|
|
|
|
//{
|
|
|
|
// case 1:
|
|
|
|
// rotateDir = transform.up * -1f;
|
|
|
|
// break;
|
|
|
|
// case 2:
|
|
|
|
// rotateDir = transform.up * 1f;
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
|
|
|
|
transform.Rotate(rotateDir, Time.deltaTime * 100f); |
|
|
|
agentRb.AddForce(dirToGo * m_SoccerSettings.agentRunSpeed, |
|
|
|
|
|
|
// Existential penalty cumulant for Generic
|
|
|
|
timePenalty -= m_Existential; |
|
|
|
} |
|
|
|
MoveAgent(actionBuffers.DiscreteActions); |
|
|
|
//MoveAgent(actionBuffers.DiscreteActions);
|
|
|
|
MoveAgent(actionBuffers.ContinuousActions); |
|
|
|
var discreteActionsOut = actionsOut.DiscreteActions; |
|
|
|
discreteActionsOut.Clear(); |
|
|
|
var contOut = actionsOut.ContinuousActions; |
|
|
|
contOut.Clear(); |
|
|
|
discreteActionsOut[0] = 1; |
|
|
|
contOut[0] = 1f; |
|
|
|
discreteActionsOut[0] = 2; |
|
|
|
contOut[0] = -1f; |
|
|
|
discreteActionsOut[2] = 1; |
|
|
|
contOut[1] = -1f; |
|
|
|
discreteActionsOut[2] = 2; |
|
|
|
contOut[1] = 1f; |
|
|
|
discreteActionsOut[1] = 1; |
|
|
|
contOut[2] = 1f; |
|
|
|
discreteActionsOut[1] = 2; |
|
|
|
contOut[2] = -1f; |
|
|
|
|
|
|
|
//var discreteActionsOut = actionsOut.DiscreteActions;
|
|
|
|
//discreteActionsOut.Clear();
|
|
|
|
////forward
|
|
|
|
//if (Input.GetKey(KeyCode.W))
|
|
|
|
//{
|
|
|
|
// discreteActionsOut[0] = 1;
|
|
|
|
//}
|
|
|
|
//if (Input.GetKey(KeyCode.S))
|
|
|
|
//{
|
|
|
|
// discreteActionsOut[0] = 2;
|
|
|
|
//}
|
|
|
|
////rotate
|
|
|
|
//if (Input.GetKey(KeyCode.A))
|
|
|
|
//{
|
|
|
|
// discreteActionsOut[2] = 1;
|
|
|
|
//}
|
|
|
|
//if (Input.GetKey(KeyCode.D))
|
|
|
|
//{
|
|
|
|
// discreteActionsOut[2] = 2;
|
|
|
|
//}
|
|
|
|
////right
|
|
|
|
//if (Input.GetKey(KeyCode.E))
|
|
|
|
//{
|
|
|
|
// discreteActionsOut[1] = 1;
|
|
|
|
//}
|
|
|
|
//if (Input.GetKey(KeyCode.Q))
|
|
|
|
//{
|
|
|
|
// discreteActionsOut[1] = 2;
|
|
|
|
//}
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// Used to provide a "kick" to the ball.
|
|
|
|