myclass a = new myclass();
vs
myclass a = getcomponent<scriptname>();
what is the difference ?
myclass a = new myclass();
vs
myclass a = getcomponent<scriptname>();
what is the difference ?
First creates a new class of type myclass.
Second one creates a reference to an existing class on the object and I don’t think it’ll work without a cast.
Becuase with a simple reference you are calling a simple script, just script, which doesn’t control any gameobject. So you need to use getcomponent to have a script of the gameobject and control variables of that gameobjects.