Search Unity

Raycasting on particles.

Discussion in 'Scripting' started by koirat, Mar 20, 2019.

  1. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    What I basically try to achieve is to have visibility functionality for my units.
    This system would take into account for example smoke cloud made out of particles.

    I would make it work by casting raycast from eyes of unit to target, when it hits the smoke I would mark target as not visible.

    As I understand I cannot just add Collision Module to particles and do the raycast. Any suggestions ?
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    You can approximate the fog ort smoke volume with bunch of sphere colliders and do things as usual. Analyzing clouds of particles won't work fast and reliable under many conditions.
     
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    Thanks for answer still your idea is not good enough. I'm reconsidering creating sphere colliders and moving them to where particles are, I know it sucks, but at least it will be less glichy more generic and scalable.
     
  4. Boz0r

    Boz0r

    Joined:
    Feb 27, 2014
    Posts:
    419
    Isn't that exactly what he suggested?
     
  5. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    Not exactly. He suggested I put some colliders around the place where particles will be and create some kind of approximated volume.