Setting Controller Force

One of the coolest features of the SymGym controller is the ability to set the amount of force required to move the arm levers and foot pedals. The force can be set to between 2 lbs and 200 lbs (limited in beta). You can use the force settings in any way imagiinable. For example, when the player is running uphill in the game, the pedal force can be increased. Or if door the player is opening in the game has a bunch of zombies behind it, the arm lever force can be increased.

In our sample game we’ll increase both the arm and leg forces as time progresses. So the longer the player plays, the harder the will have to work!

We’ll initialize all the forces in the Start() method of the GameController.cs script. But first we’ll need a variable to track the force and another to determine amount to increment over time.

  public int resistance;
  public float resistanceIncrment = .01f
  void Start() {
    if (sgStub != null) {
      sgState = sgStub.Call<AndroidJavaObject>("getState");

      sgState.Call<void>("setResistanceAll", 0);
      }                                      
   }

Increment force during game play, reset to zero force on game over

  void Update() {
    if (sgStub != null) {
      sgState = sgStub.Call<AndroidJavaObject>("getState");
      .
      .
      .
      if (gameOver) {
        restartText.text = "Press Trigger to Restart";
        restart = true;

        // reset to zero force on game over
        sgState.Call<void>("setResistanceAll", 0);
      }
      else {
        resistance = (int) (resistance + resistanceIncrement);
        sgState.Call<void>("setResistanceAll", resistance);
      }
    }
  }