I’m new with Unity and I’ve a problem with reading the variable: ‘Selected’ from another script . I’ve read some documentation and that’s not working. Can someone help me? Thanks
125TargetingScript.js
private var Selected = false;
function Update ()
{
if(Input.GetKey("r"))
{
Selected= false;
}
}
function OnMouseUp()
{
if(Selected == false)
{
Selected= true;
}
}
----------
**TargetingLight.js**
> var newSelected = false;
function Update ()
{
var TargetingScript : Object;
TargetingScript = GetComponent("TargetingScript");
if(TargetingScript.Selected == true)
{
newSelected = true;
}
}
I’m sorry, I can’t place the script’s in a quote for some reason.