CharacterController controller = GetComponent(CharacterController);
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."
Answer by Jessy
Aug 22, 2010 at 02:44 PM
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.)
didn't know of this but it sure is cleaner so thanks :D
woa woa woa what's wrong with this?
bunch of links are missing?
Answer by matyicsapo
Aug 22, 2010 at 02:36 PM
CharacterController controller = (CharacterController)GetComponent(typeof(CharacterController));
CharacterController controller = GetComponent(typeof(CharacterController)) as CharacterController;
CharacterController controller = GetComponent("CharacterController") as CharacterController;
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
2 People are following this question.
How do I get an NPC to follow the player and then allow the player to swap between characters
Why won't my character look up?
2.5D platformer main character collision
Player falls through floor after 10-20 seconds and above certain resolution consistantly(Bug?)
Problem with Movement Script