VerticalSlider

I want to control the speed of a ship with a vertical slider. I have the vertical slider but not sure how to get it to work with the speed part of the ship. 2 buttons control the speed. - = the - slows the ship down and the = makes it go faster.

1450546--78388--$speed.jpg

Here is all I have in the way of the slider.

	public float vSliderValue = 0.0F;
	void OnGUI () {
		GUI.Box(new Rect(10, 10, 200, 200), "Target : " +target);
		vSliderValue = GUILayout.VerticalSlider(vSliderValue, 0.0F, 1500.0F);
	}
	}

Key input info here: http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKey.html

You’d probably do something like:

void Update() {
if (Input.GetKey(KeyCode.Plus)) {
vSliderValue += 100;
speed = vSliderValue;
}
}

And similar for the reverse.

Awsome dude you were a lot of help ^^. I used what you gave me here and made this and btw it works now :slight_smile:

:

private var vSliderValue = 0.0F;
function OnGUI () {
		vSliderValue = GUI.VerticalSlider(new Rect(25, 25, 10, 500), vSliderValue, 0.0F, 5.0F);
			vSliderValue += 0;
			trueSpeed = vSliderValue;
		}

For those of who like me who don’t know. This part: (new Rect(25, 25, 10, 500) more about the part at the end 500. That is the size of the bar. This part here: 10, 500), vSliderValue, 0.0F, 5.0F); more the part at the end 5.0F); that is the increments the bar value is. I really hope this helps some one else out. It took all night and the better half of this day to figure out that’s where I was having the problem. ^^ Take care all.