Question by
riobusor66 · Jan 02, 2018 at 06:40 PM ·
physics.overlapsphere
Physics.OverlapSphere not working...
I have make a script for detect player and destroy the gameobject but it not working, the "clicked" variable in my script is changed to true by an another script. debug log "ok" is not displayed in the console.
var clicked : boolean = false;
var coord : Vector3;
function Update(){
if (clicked){
coord = Vector3(transform.position.x, transform.position.y, transform.position.z);
var hitColliders = Physics.OverlapSphere(coord, 100);
if (hitColliders[0].tag == "Player"){
Debug.Log("ok");
Destroy (gameObject);
Debug.Log("ok");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Ground Check Issue 1 Answer
I need help with the OverlapSphere thing 0 Answers
How to do a Placement object properly? 0 Answers
How to easily find nearest object? 0 Answers