Physics.OverlapSphere not working
if (isactive == true)
{
ParticleManager.instance.PlayPlarticles(1, 0.2f, Color.yellow, 1f, transform.position);
explodetime--;
if (explodetime == 0)
{
Collider[] hitColliders = Physics.OverlapSphere(transform.position, exploderadius);
for (int i = 0; i < hitColliders.Length; i++)
{
Debug.Log(hitColliders[i].name);
hitColliders[i].SendMessage("Damage", 10);
}
Destroy(gameObject);
}
}
it doesnt seem to work, no names are displayed in log and no damage is made.
Answer by Oribow · Apr 10, 2016 at 06:10 PM
There is nothing wrong with your script. Tried it myself. May check your exploderradius. You can visualize it by adding this:
void OnDrawGizmos()
{
Gizmos.DrawWireSphere(transform.position, exploderadius);
}
$$anonymous$$y explode radius has been 1f, 10f and 100f. Any worked
They didnt when I tried. Does this function need the gameobject youre using it in have a collider? Because im using it as a trigger.
Your answer
Follow this Question
Related Questions
[SOLVED] Frictionless space 1 Answer
Unity 5.3 Collider2D not working 2 Answers
how to make force inversely proportional to the distance 0 Answers
OnTriggerEnter2D calculate wrong collision when Object is scalling 0 Answers
My UI object onclick event does not work if created from code, but works outside of it 0 Answers