I have a NonPlayabledCharacter gameObject that i find like this
FindObjectWithTag(“NonPlayableCharacter”); //using a string reference
once I find this gameobject, i need to be able to further determine if it has other script attached to it,
gameObject.GetComponent(“I Need To Use A String Reference”);
is there a way to determine is a component is attached to a game object this way
Well, I would assume it would return NULL if there wasn’t one attached, so try putting it in an if statement. Actually, just tested, it works fine in Unityscript.
right but I’m passing in a string reference in the editor, im creating a mini map, this maps finds all NonPlayableCharacters, depending on what type of NPC it is, it will assign a specific markers, these markers are also assigned in the editor
Right, well by putting the GetComponent in an if statement, you can determine if a component is attached…? Not sure what you want it to do? It should take a string variable from the editor public vars just find.
var StringHere;
if(gameObject.GetComponent(StringHere))
Do something;
No?
wow, i’m not sure how i missed that, i’m used to doing it like this, GetComponent(), i’ve never used GetComponent(), I’ll pretend I didn’t ask this question, thanks man