- Home /
Position slider?
Many racing games will show the player's position relative to the level on a map, is there anyway to do this using unity's built in horizontal slider GUI element? So one end represents one position(I only want to measure the z axis), and the other end represents another, and the buttons position shows the player how close they are to the end of the level (the level is one way only, so perhaps the race track comparison was a bit off). Thanks
EDIT: I tried do to what yoyo suggested, but I get the error
"Assets/NewBehaviourScript.js(6,27): BCE0023: No appropriate version of 'UnityEngine.GUILayout.HorizontalSlider' for the argument list '(float, UnityEngine.Transform, UnityEngine.Transform)' was found."
How do I convert the player's position to a value?
var player : Transform; var z_start: Transform; var z_end : Transform;
function OnGUI (){ GUILayout.HorizontalSlider(player.transform.position.z, z_start, z_end); }
Answer by yoyo · Jan 10, 2011 at 04:26 AM
You mean like this?
GUILayout.HorizontalSlider(player.transform.position.z, z_start, z_end);
Since you do nothing with the return value (though letting the user drag themselves through the level with the slider might be an interesting cheat :-), the slider thumb will be effectively disabled from user control.