How do I get the Rotation X value from the main camera from another child object of the fps.
Basically I have the FPS (parent) script and 1 child object needs a value from another child object.
How do I get the Rotation X value from the main camera from another child object of the fps.
Basically I have the FPS (parent) script and 1 child object needs a value from another child object.
Here is how I got it working:
A sphere with 2 empty game objects as children (ChildA and ChildB). Each has a script attached, ChildAScript and ChildBscript
here is ChildAScript:
var some:float;
function Start () {
some =5;
}
ChildBScript:
var go:GameObject;
var sc:ChildAScript;
function Start () {
sc=go.GetComponent(ChildAScript);
}
function Update(){
if(Input.GetKeyDown(KeyCode.Space))
sc.some+=10;
Debug.Log(sc.some);
}
Drag the source object in the go slot in the inspector. Now I can print the value of the variable of A from B and I can also increase its value from B.