Hi there,
I have read a bunch of posts about this but I guess I need a little clarity.
First question: is it a bad idea to have spaces in script names (ie… script player.js)
I feel that perhaps this is obstructing me from accessing the components of that script.
I’ve used this before
var enemyScript = hit.transform.GetComponent(cubebehavior);
enemyScript.numberOfClicks -= 1;
with quite a bit of success but this was utilizing a raycast to grab the target object plus my script name was all one word, in this next case I just want to access another script in a more abstract fashion, like this:
// Inspector variable
var p :Transform;
if(hit.gameObject.tag == "bullet"){
var pScript = p.transform.GetComponent("script player");
pScript.playerScore += 10;
Now, with this new method I can’t seem to get component access (specifically variable access)… Is this because I’m using a transform rather than a game object, because I’ve got spaces in my script name and therefor have to search for a string or am I just doing this all wrong.
Thanks in advance!