public override void OnActionReceived(ActionBuffers actionBuffers) { ActionSegment <int> actions = actionBuffers.DiscreteActions; int rotation = actions[0]; int movement = actions[1]; int attack = actions[2]; currentAttackState = (AttackState)attack; currentMovementState = (MovementState)movement; currentRotationState = (RotationState)rotation; switch (currentRotationState) { case RotationState.LEFT: rb.transform.Rotate(Vector3.down, velocityRotateY); break; case RotationState.RIGTH: rb.transform.Rotate(Vector3.up, velocityRotateY); break; } switch (currentMovementState) { case MovementState.FORWARD: rb.velocity = this.transform.forward * velocityMovement; break; case MovementState.BACKWARD: rb.velocity = -this.transform.forward * velocityMovement; break; } if (currentAttackState == AttackState.ATTACK && timeLastBullet >= 1.0f / rateFire) { GameObject shellToSend = null; foreach (GameObject s in shells) { if (!s.activeSelf) { shellToSend = s; } } if (shellToSend != null) { shellToSend.transform.position = this.spawnBullet.position; shellToSend.transform.rotation = this.transform.rotation; ShellController controller = shellToSend.GetComponent <ShellController>(); controller.BoomBoom(healthController); timeLastBullet = 0; } } }