- Home /
Question by
LWill · Dec 21, 2013 at 11:15 PM ·
errorvariableinitialization
Variabletype
Hello,
what type of variable do I need to use when I want to initialize a variable which holds a whole class.
This is my initialization:
class TasseMoovementVerweis;
That is what the variable is for:
TasseMoovementVerweis= new TasseMoovement();
TasseMoovementVerweis=gameObject.AddComponent("TasseMoovement");
animator2=TasseMoovementVerweis.animator;
Unity says (without the initialization): the name TasseMovementVerweis doesn't exist in the current context
I thought I have to initialize TasseMovementVerweis. Is that right? Do you know how to solve this error?
Thank you for your help!
Comment
Best Answer
Answer by robertbu · Dec 21, 2013 at 11:27 PM
C#
Declare it like this:
TassMovement tasseMovementVerweis;
Initialize it like this:
tasseMovementVerweis = gameObject.AddComponent<TasseMovement>();
Javascript:
Declare it like this:
var tasseMovementVerweis : TasseMovement;
Initialize it like this:
tasseMovementVerweis = gameObject.AddComponent(TasseMovement);
Note by convention, lower case letters start variable names and upper case letters start classes and functions/methods.