Hi all,
this is driving me crazing so I hope someone can help. I have a First person controller and i want the user to be able to vary the height with a Horizontal slider. Sounds easy huh? well I have cobbled together a script to do this, trouble is every time the user makes the character controller height bigger the character just falls thru the ground object.
Any Ideas anyone?
heres what I have so far:
var objectName = "First Person Controller";
var scriptName = "CharacterController";
var myScriptObject : CharacterController;
var newValue : float;
var currentValue : float;
function Awake()
{
object = GameObject.Find(objectName);
if ( object != null )
{
myScriptObject = object.GetComponent(scriptName);
if( myScriptObject != null )
{
currentValue = myScriptObject.height;
newValue = currentValue;
}
}
}
function OnGUI ()
{
if(myScriptObject != null)
{
newValue = myScriptObject.height;
}
GUI.Label (Rect (10, 10, 80, 20), "Height");
newValue = GUI.HorizontalSlider (Rect (25, 25, 100, 30), newValue, 0.0, 10.0);
}
function Update()
{
myScriptObject.height= newValue;
}