Hi,
I am trying to reference the character controller from a script attached to another object (for example, from a script attached to a cube). It is easy to just leave the “controller” var public and drag the character controller on to it in the inspector, but I would rather reference it entirely by code – something like below, which does not work. Any suggestions? Thanks. Zaffer
private var controller : CharacterController;
function Start(){
controller = gameObject.GetComponent(CharacterController);
Debug.Log(controller);
}
P.S. I seem to be having trouble formatting my code – using the “pre” and “code” tags which don’t seem to work very well. Any suggestions? Thanks.