can someone please help me with physics.OverlapSphere.
I am trying to make all gameObjects active gameObject.SetActive(true) in sphere with radius 30 and position of player.trasform.position.
I was trying with this incomplete code, but I dont know what to do.
#pragma strict
var player : GameObject;
var radius = 30;
var colliders : Collider[];
function OnCollisionEnter(collision : Collision) {
colliders = Physics.OverlapSphere (player.transform.position, radius);
for (var i = 0; i < colliders.Length; i++) {
}
}
#pragma strict
var player : GameObject;
var radius = 30;
var colliders : Collider[];
function OnCollisionEnter(collision : Collision) {
colliders = Physics.OverlapSphere (player.transform.position, radius);
for (var i = 0; i < colliders.Length; i++) {
colliders*.gameObject.SetActive(true);*
} } Sidenote You’ve placed it inside the OnCollisionEnter() method of the Player. This means it will get run everytime the gameObject that contains this script starts a collision with another object. Maybe you missed that?