Hi all, i’ve read already that a class not inheriting from MonoBahaviour cant do some stuff, actually, im creating a class to handle points coordinates and from within ths class i cant do the GameObject.Find, is there another way ?
Using GameObject.Find does not require a class to derive from anything. The only requirement is that you are using UnityEngine.
The title of the thread also doesn’t make sense; what issue are you having with a constructor?
Sample code would be helpful.
I have a monoBehaviour that is instantiating throught the “new” keyoword, a custom class KJoint, isnide the KJoint class i try to get a reference usinf GameObject.Find() and i cant, for the thread title u are right, i made confusion, is just that i needed a constructor so i used a custom class KJoint. STill cant get that reference from Kjoint that is not a monobehaviour
When you say you ‘can’t’, what do you mean? Compiler error? Run-time error? Something else?
_gObject = GameObject.Find(_label);
Debug.Log(_gObject );
it doesnt print the object, and this function is called byt anohter NON monobehaviourclass , if that ca be useful
where _gObject is a private declared gameObject
ok, for som strange reason now it worked, i declared public instead of private the variables i was using, thank you indeed for you interest, i appreciated it indeed ![]()
but if i try to Debug.Log(_gObject.transform.rotation) log is stucked and i cant print it…what am i doing wrong ?
if i pass the _gObject into constructor i can print the object butnot access it, and if i do that :
_gObject = GameObject.Find(_label);
Debug.Log(_gObject);
i cant print anything, like that find doesn wrok from inside this script, maybe cos is not attached to a gameobject ?
Without more complete code, I won’t know what you are saying. Do be advised that you can freely use constructors, but only if they take parameters. The bottom of this page provides warnings about the parameterless constructor, which Unity will call without your explicit command:
http://unity3d.com/support/documentation/ScriptReference/index.Writing_Scripts_in_Csharp.html
i should post a lot of code, and actually I dont get how it works, my goal is this :
i have different fbx models with joint,
I have a monobeahviour script that is getting properties over the net
i have a class to create a model handler so i can decide what to do, i need to move the joint of that model
now, i can shift+canc all the code, what im missing, cos im new to unity, is the best flow to achieve the control of model joints, any idea to point me ?