help with GUI "Boost" button...

i am working on a arcade flight sim game for iPhone. I need to create a “boost” button that would boost speed of plane as button is pressed and return to normal as depressed (obviously). I have studied the script reference and gui reference but cannot get my head around it. here is button script…

function OnGUI () {
if (GUI.RepeatButton (Rect (Screen.width - 100,Screen.height - 50,100,50), “Boost!”)) {
// This code is executed every frame that the RepeatButton remains clicked

}
}

i need that button script to increase this script below…

thisRigidbody.AddForceAtPosition( thisTransform.forward * 1000, forceThrust.position );

need to increase the “1000” integer when button is pressed…i do not have a throttle control, plane flies at constant speed when game starts, just want to add a little speed boost to help game play.

thanks for the assistance :slight_smile:

private var isBoosted : boolean = false;
private var normalSpeed : int = 1000;
private var boostSpeed : int = 2000;

function OnGUI() {
  isBoosted = false;
  if (GUI.Button(Rect(...), "Boost!") {
    isBoosted = true;
  }
}

Then, in the Update() / FixedUpdate() / where ever you apply your forces,

var speed : int;
if (isBoosted) {
  speed = boostSpeed;
} else {
  speed = normalSpeed;
}
thisRigidbody.AddForceAtPosition( thisTransform.forward * speed, forceThrust.position );

thank you!!!

thanks for help, still having issues, i sent you a PM.