HI gang, this script works almost perfectly except it activates and deactivates wherever I click in the main camera view Insted of only activating when I click on the object with the script attached to it
#pragma strict
public var Select : Moving;
// this script toggels to turn on and of Selct on Click with raycast like a boss.
function Start () {
Select = GetComponent("Moving");
}
function Update () { if (Input.GetMouseButtonDown(0)){
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if (Physics.Raycast(ray, hit)){
Select.enabled = !Select.enabled;
}
}
}
// feel freee to use this script for yourselves XD