- Home /
click (raycast) single particle
Hy You all, is it possible to raycast a single particle? I've tried without success! with and without the world particle collider and I'm pretty sure the ray casting code works fine, 'cause it does function with other game objects.
Thanks in advance
void Update () {
if(Input.GetButtonDown("Fire1"))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if(Physics.Raycast(ray, out hit, 100.0f))
{
Debug.Log("hit");
}
}
}
Answer by TowerOfBricks · Dec 28, 2011 at 03:43 PM
Particles have no colliders as such (the World Collider doesn't work either I think), they are handled as points so raycasting won't work. Instead you could gather the particles in an array (particleEmitter.particles) and check how close they are to your ray. Might be a bit troublesome if you've got many particle systems though.
AH! now I see :) thank You, I'll follow Your advice, the emitter I'm using, does not generate many particles.. should work like a charme!
Sorry for the delay.. It worked like a charme! thank's a lot :-)