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 post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
1 Person is following this question.
Can I prevent player through terrain when terrain height is modified at runtime?
I wonder Why has so little resources To this important topic؟
Character controllers against each other