public void MoveAgent(float[] act) { var dirToGo = Vector3.zero; var rotateDir = Vector3.zero; m_KickPower = 0f; var forwardAxis = (int)act[0]; var rightAxis = (int)act[1]; var rotateAxis = (int)act[2]; var service = (int)act[3]; switch (forwardAxis) { case 1: dirToGo = transform.forward * m_ForwardSpeed; m_KickPower = 1000f; 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; } switch (service) { case 1: break; case 2: if (this.isServing && area.phase == RectArea.GamePhase.Start) { area.Service(this); } else if (area.phase == RectArea.GamePhase.Play) { area.Hit(this); } break; } transform.Rotate(rotateDir, Time.deltaTime * 100f); agentRb.AddForce(dirToGo * m_Settings.agentRunSpeed, ForceMode.VelocityChange); }