|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public override void AgentAction(float[] act) |
|
|
|
public override void AgentAction(float[] vectorAction, string textAction) |
|
|
|
for (int k = 0; k < act.Length; k++) |
|
|
|
for (int k = 0; k < vectorAction.Length; k++) |
|
|
|
act[k] = Mathf.Clamp(act[k], -1f, 1f); |
|
|
|
vectorAction[k] = Mathf.Clamp(vectorAction[k], -1f, 1f); |
|
|
|
limbRBs[0].AddTorque(-limbs[0].transform.right * strength * act[0]); |
|
|
|
limbRBs[1].AddTorque(-limbs[1].transform.right * strength * act[1]); |
|
|
|
limbRBs[2].AddTorque(-limbs[2].transform.right * strength * act[2]); |
|
|
|
limbRBs[3].AddTorque(-limbs[3].transform.right * strength * act[3]); |
|
|
|
limbRBs[0].AddTorque(-body.transform.up * strength * act[4]); |
|
|
|
limbRBs[1].AddTorque(-body.transform.up * strength * act[5]); |
|
|
|
limbRBs[2].AddTorque(-body.transform.up * strength * act[6]); |
|
|
|
limbRBs[3].AddTorque(-body.transform.up * strength * act[7]); |
|
|
|
limbRBs[4].AddTorque(-limbs[4].transform.right * strength * act[8]); |
|
|
|
limbRBs[5].AddTorque(-limbs[5].transform.right * strength * act[9]); |
|
|
|
limbRBs[6].AddTorque(-limbs[6].transform.right * strength * act[10]); |
|
|
|
limbRBs[7].AddTorque(-limbs[7].transform.right * strength * act[11]); |
|
|
|
limbRBs[0].AddTorque(-limbs[0].transform.right * strength * vectorAction[0]); |
|
|
|
limbRBs[1].AddTorque(-limbs[1].transform.right * strength * vectorAction[1]); |
|
|
|
limbRBs[2].AddTorque(-limbs[2].transform.right * strength * vectorAction[2]); |
|
|
|
limbRBs[3].AddTorque(-limbs[3].transform.right * strength * vectorAction[3]); |
|
|
|
limbRBs[0].AddTorque(-body.transform.up * strength * vectorAction[4]); |
|
|
|
limbRBs[1].AddTorque(-body.transform.up * strength * vectorAction[5]); |
|
|
|
limbRBs[2].AddTorque(-body.transform.up * strength * vectorAction[6]); |
|
|
|
limbRBs[3].AddTorque(-body.transform.up * strength * vectorAction[7]); |
|
|
|
limbRBs[4].AddTorque(-limbs[4].transform.right * strength * vectorAction[8]); |
|
|
|
limbRBs[5].AddTorque(-limbs[5].transform.right * strength * vectorAction[9]); |
|
|
|
limbRBs[6].AddTorque(-limbs[6].transform.right * strength * vectorAction[10]); |
|
|
|
limbRBs[7].AddTorque(-limbs[7].transform.right * strength * vectorAction[11]); |
|
|
|
float torque_penalty = act[0] * act[0] + act[1] * act[1] + act[2] * act[2] + act[3] * act[3] |
|
|
|
+ act[4] * act[4] + act[5] * act[5] + act[6] * act[6] + act[7] * act[7] |
|
|
|
+ act[8] * act[8] + act[9] * act[9] + act[10] * act[10] + act[11] * act[11]; |
|
|
|
float torque_penalty = vectorAction[0] * vectorAction[0] + |
|
|
|
vectorAction[1] * vectorAction[1] + |
|
|
|
vectorAction[2] * vectorAction[2] + |
|
|
|
vectorAction[3] * vectorAction[3] + |
|
|
|
vectorAction[4] * vectorAction[4] + |
|
|
|
vectorAction[5] * vectorAction[5] + |
|
|
|
vectorAction[6] * vectorAction[6] + |
|
|
|
vectorAction[7] * vectorAction[7] + |
|
|
|
vectorAction[8] * vectorAction[8] + |
|
|
|
vectorAction[9] * vectorAction[9] + |
|
|
|
vectorAction[10] * vectorAction[10] + |
|
|
|
vectorAction[11] * vectorAction[11]; |
|
|
|
|
|
|
|
if (!IsDone()) |
|
|
|
{ |
|
|
|