Search Unity

Do Particle Systems render sprites at a different scale?

Discussion in '2D' started by ShervinM, May 23, 2020.

  1. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Heyo!

    So my repro is pretty simple here. I have an object that has a sprite renderer and an animator. I also have a script attached attached that feeds the spriterenderer.sprite to a particle system. The particle is set to emit using texture sheet animation, using only 1 sprite reference ever (which keeps getting hot swapped out at runtime with the aforementioned script).

    Now the problem I'm seeing is that the emitted sprite is distorted in its scale. What i've highlighted in red are eye-balled adjustments i had to make to the start size of the particles so that they match the same size as what the sprite renderer shows.

    So simply put, why would the particle system (despite having a (1,1,1) scale on both the object and the start size param in the particle system) render the exact same sprite a different scale than what the sprite renderer would show?

    upload_2020-5-22_22-4-38.png
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    I think it’s supposed to use the size of the sprite.. a bug report would be useful so we can double check this, and figure out if there any settings in your sprite that we have failed to take into account.
     
    karl_jones likes this.
  3. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Hey @richardkettlewell ! Thanks for the quick reply.

    So I did some testing in a brand new project (2019.3.1f1) and it turns out that the Pixels Per Unit (PPU) property has no effect on the particle rendering (while it does on the sprite renderer). Check out this simple repro project with the sample scene i made. Just simply select the particle system to preview it rendering the sprite above the sprite renderer.

    The sizes are different. You can adjust the PPU but the particle system wont respond to it.

    Repro Project:
    https://drive.google.com/file/d/17_RO5mlxT8HRHjBJKnRvmBLzvPpa3hd5/view?usp=sharing
     
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Thank you that’s amazing that you narrowed it down like this!

    If you report a bug through the bug reporter (help/report a bug in the editor) you’ll get notifications when we fix it, plus it makes it easier for me to backport if I have a report saying you need it fixed in a certain version of Unity - but if you’d prefer not to, I understand, we can fix it anyway, just you won’t get notified ;)

    You can mention me/this forum link to get it processed by QA without any potential hassle I.e them asking extra questions.
     
    ShervinM likes this.
  5. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Thanks @richardkettlewell,

    I've went ahead and filed the bug.

    Thanks again for your help, I very much appreciate it :)
     
    MelvMay and richardkettlewell like this.
  6. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Thanks! What’s the case number?
     
  7. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    richardkettlewell likes this.
  8. RavenmoreArt

    RavenmoreArt

    Joined:
    Aug 28, 2014
    Posts:
    4
    **Necromancy**

    Any updates on this?
    I just ran into the same issue, PPU does not affect particle sprites in any way, so sprites I try to emit as particles have different sizes than their regular GameObject counterparts.

    I couldn't find this issue on the tracker by ID with the Search function :(
     
  9. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Hey, unfortunately we decided not to fix this.

    There is no obvious way to map PPU to particle sizes (as far as we can see, anyway?) because one is a pixel scaling factor and the other is world units.

    It would also be difficult to apply this without unexpectedly changing existing content for some users.

    We decided it was probably safest to let users write a script to apply the PPU to the particle size themselves, so you can control how one maps to the other.
     
  10. RavenmoreArt

    RavenmoreArt

    Joined:
    Aug 28, 2014
    Posts:
    4
    Thanks for the quick reply! Perfectly understandable, I'll go the custom script route :)

    This seems to have worked for me. Apparently the particle size is calculated based on sprite width.
    I'm not sure the result is 100% accurate, but it cerainly is close enough.

    Code (CSharp):
    1.  
    2. var main = particles.main;
    3. main.startSize = new ParticleSystem.MinMaxCurve(ItemSprite.rect.width/ItemSprite.pixelsPerUnit);
     
    Last edited: Sep 14, 2020
    koyodi, loir, AlejMC and 2 others like this.