I know this has been asked many times. I have spent 4 hours looking over threads and I still don’t understand how this works… And yes, I read this page Link So if anyone has the patience to explain it one more time I would appreciate it.
Here is what I have:
Object “Mover” has script named “MoverControls”
with - var Speed:float=0;
Object “Player” has a script named “PlayerControl”
with - var charSpeed:float=0;
The Speed value is constantly updating and I want to get the Speed value from “MoverControls” into my “PlayerControl” script so that I can use its value in other spots.
I tried placing this in my “MoverControl” script:
private var playerControl:PlayerControl;
function Update(){
playerControl=gameObject.Find("Player").GetComponent(PlayerControl);
playerControl.charSpeed = Speed;
}
but I keep getting this message:
"The name ‘PlayerControl’ does not denote a valid type (‘not found’)
Both the MoverControls and PlayerControl are in the Resources/Scripts folder, which is in the top level of the game hierarchy. I tried moving them to different folders, however I got the same result.
None of my scripts have spaces in them, and they are both .js files.
Does my scene hierarchy matter? Here is what I have: