IEnumerator FakeFixedUpdate() { WaitForSeconds wait = new WaitForSeconds(Time.fixedDeltaTime); //change with CustomPhysics while (true) { if (Input.GetAxisRaw(vertInput) != 0 || Input.GetAxisRaw(horInput) != 0) { lastFrame = true; moves.Move(Vector2.ClampMagnitude(new Vector2(Input.GetAxis(horInput), Input.GetAxis(vertInput)), 1f)); } else if (lastFrame) { moves.Move(Vector2.zero); lastFrame = false; } yield return(wait); } }
public override void AgentAction(float[] vectorAction, string textAction) { base.AgentAction(vectorAction, textAction); if (vectorAction[0] != .0f && vectorAction[1] != .0f && vectorAction[0] <= 1f && vectorAction[1] <= 1f && vectorAction[0] >= -1f && vectorAction[1] >= -1f) { moves.Move(Vector2.ClampMagnitude(new Vector2(vectorAction[0], vectorAction[1]), 1f)); AddReward(.001f); } if (!attacks.isCharging && vectorAction[2] >= .5f) { attacks.Charge(); AddReward(.07f); } else if (attacks.isCharging && vectorAction[2] > 0 && vectorAction[2] < .5f) { attacks.Shock(); AddReward(.015f * attacks.normalizedCharge); } AddReward(-.005f); }