Hi,
Im setting a boolean to true when Physics.OverlapSphere how would I make the boolean false when no longer overlapping?
var radius = 5.0;
var colliders : Collider[];
function Update()
{
var spherePos : Vector3 = transform.position;
colliders = Physics.OverlapSphere (spherePos, radius);
for (var hit : Collider in colliders)
{
if (!hit) continue; // avoid null references (should not occur, but...)
if (hit)
{
hit.gameObject.GetComponent(Lighter).selectable = true;
}
}
}
//to draw the sphere
function OnDrawGizmosSelected () {
// Draw a yellow sphere at the transform's position
Gizmos.color = Color.yellow;
Gizmos.DrawSphere (transform.position, radius);
}
I’ve tried this and a few other things but to no avail
else
{
hit.gameObject.GetComponent(Lighter).selectable = false;
}
when I move the sphere out of range it does update the collider list (removing this object) but i cant change selectable to false?