# GUI Display

So i am making a Space Game In our Solar System for science.
I have a rotater script that makes each planet orbit around the sun. I want to have their speeds Displayed in a GUI Box in the corner. This is the script:

``````var xSpeed : float = 1;
``````

var ySpeed : float = 1;
var zSpeed : float = 1;

var manual : boolean = false;

function Update ()
{

``````if( !manual )
{

transform.RotateAround( transform.position, Vector3.right, ySpeed * Time.deltaTime );
transform.RotateAround( transform.position, Vector3.up, xSpeed * Time.deltaTime );
transform.RotateAround( transform.position, Vector3.forward, zSpeed * Time.deltaTime );

}
else
{

if( Input.GetAxis("Horizontal") != 0 )
{

transform.RotateAround( transform.position, Vector3.up, Input.GetAxis("Horizontal")*xSpeed * Time.deltaTime );

}

if( Input.GetAxis("Vertical") != 0 )
{

transform.RotateAround( transform.position, Vector3.right, Input.GetAxis("Vertical")*ySpeed * Time.deltaTime );

}

}
``````

}

Is there a way to show the X speed for each planet? they each have this script with a different x-rotation Value

I think if you use the OnGUI function you should be able to get it set up for how you want it.

void OnGUI()
{
GUI.Box(new Rect(50, 50, 150, 20), “Planet Name’s Speed:” + xSpeed);
}

the Rect function goes (x position, y position, linewidth, lineheight), add text in " "'s here and to display you rvariables use the + before it like shown. hope this helps.

So, I tried This:

``````var xSpeed : float = 1;

``````

var ySpeed : float = 1; var zSpeed : float = 1;

var manual : boolean = false;

function Update () {

``````if( !manual )
{

transform.RotateAround( transform.position, Vector3.right, ySpeed * Time.deltaTime );
transform.RotateAround( transform.position, Vector3.up, xSpeed * Time.deltaTime );
transform.RotateAround( transform.position, Vector3.forward, zSpeed * Time.deltaTime );

}
else
{

if( Input.GetAxis("Horizontal") != 0 )
{

transform.RotateAround( transform.position, Vector3.up, Input.GetAxis("Horizontal")*xSpeed * Time.deltaTime );

}

if( Input.GetAxis("Vertical") != 0 )
{

transform.RotateAround( transform.position, Vector3.right, Input.GetAxis("Vertical")*ySpeed * Time.deltaTime );

}

}

``````

} function OnGUI () { (GUI.Box(Rect(20, 40, 80, 80), "Jupiter:" + xSpeed)); }

And it worked... Now, For my presentation, I want the number to fluctuate, So even though the x-speed for my planet is 13.07, I want it to have a constant fluctuation between 13.02-13.22 Is there a way to do this? and I would want the fluctuation to be constant..