Search Unity

Machinegun built on particle emitter (world collisions enabled) behave unreliably

Discussion in 'Physics' started by andrew-lukasik, Apr 23, 2015.

  1. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    Hi,
    My machinegun mechanics based on Particle System (world collisions enabled, collision quality set to High) behave unreliably for some reason. Machineguns sometimes work flawlessly... and sometimes not at all (particles start to go through everything). Any tips on what may be happening here or how to go about tracking this issue down?


    You may take a look yourself how it behaves in this build:
    (click to run in browser)



    (unity version 5.0.1f1)
     
    Last edited: Apr 23, 2015
  2. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    I noticed that this happens when particles from this ParticleSystem are spread out on scene too much
     
  3. trudeaudm

    trudeaudm

    Joined:
    Apr 17, 2013
    Posts:
    116
    I am pretty sure unity automatically drops collision quality on particles if things are getting "busy". So using particles as projectiles might not be your best option.
     
    andrew-lukasik likes this.
  4. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    Is there a way to override this one particular behavior somehow? Because it's incredibly easy and fun to make things like machineguns etc. using ParticleSystem since messages OnParticleCollision were introduced.
     
  5. trudeaudm

    trudeaudm

    Joined:
    Apr 17, 2013
    Posts:
    116
    But why not just use a raycast or rigidbody? The only time I use particles collisions for projectiles if in the case of flamethrower like weapons.
     
  6. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    Yes, raycasts are certainly efficient a way of doing this. But I would love to have bullets visibly flying around (meaning: slower than light speed) and there this slow-motion aspect in this game which makes it harder to fake/predetermine collisions precisely.
    I can see that static meshes wouldn't be a problem; just simple calculation of a hit delay from distance/speed. But I'm not sure how to obtain precise results when considering moving objects (which could obscure line of flight x time after initial raycast). Still seems possible but rather complicated (?)
     
  7. trudeaudm

    trudeaudm

    Joined:
    Apr 17, 2013
    Posts:
    116
    So why not use a rigidbody bullet?
     
  8. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    That's right. This is what I'll probably end up doing here :T
    I'm thinking about implementing this as a pool of invisible ridigbody spheres + ParticleSystem to serve merely as a renderer for them all. Pity that ParticleSystem can't handle this tho; it almost works.
     
    Last edited: Apr 27, 2015