system
August 22, 2010, 2:28pm
1
I got problems when trying to access Character controller from C# file but the same theory on Javascript works.
C#
CharacterController controller = GetComponent(CharacterController);
JavaScript
var controller : CharacterController = GetComponent(CharacterController);
Can anyone help me how can I access the character controller from C#...
The errorss I am getting is
"Expression denotes a type, where a varuable, value or method group was expected."
Jessy
August 22, 2010, 2:44pm
3
What Matyi Csapo offered will work. I prefer not so many glyphs on my screen, so I use the generic version:
CharacterController controller = GetComponent<CharacterController>();
You'll find this right on the documentation page . (It is missing a semicolon, but this page has been rewritten for the 3.0 documentation and looks error-free there.)
`CharacterController controller = (CharacterController)GetComponent(typeof(CharacterController));`
OR
`CharacterController controller = GetComponent(typeof(CharacterController)) as CharacterController;`