Question by
Misthra-Games · Jan 16, 2016 at 01:54 AM ·
c#getcomponent
GetComponent not working
I am not understanding why this does not work
yay.png
(5.1 kB)
Comment
Best Answer
Answer by hulahoolgames · Jan 16, 2016 at 02:12 AM
Try doing it in the Start or Awake function instead of in the class scope:
void Awake() {
CharacterController cont = gameObject.GetComponent<CharacterController>();
}
Your answer
Follow this Question
Related Questions
Left hand side of an assignment must be a variable, a property or an indexer 1 Answer
GetComponent null, but it's attached to gameobject 1 Answer
Changing image color from other object's script (glitch)? 0 Answers
Getting typename from collection. 0 Answers
Game Manager can't decide what the instance of the object is despite just making an instance of it 1 Answer