0
\$\begingroup\$

I'm using a Particle System with the Shape in the shape module set to Sprite Renderer, and the Type set to Triangle.

As far as I can tell, the default behavior is for the Particle System's emission rate to be independent of the surface area of the Sprite's mesh triangles. In other words, the bigger the Sprite, the less particles per unit area are emitted.

I would like to make it so that the emission rate of the particles scales linearly with the area of the Sprite Renderer's current Sprite. Is there a simple way to do this in the inspector? Or would I have to do it through scripting (maybe finding the area of the Sprite's Sprite.triangles and using that to scale the emission module's Rate over Time/Rate over Distance or something)?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I think your latter guess would be the way to do it. \$\endgroup\$ Commented Nov 11, 2024 at 3:13
  • \$\begingroup\$ @DMGregory Thanks for the comment! I suppose the followup questions would be: 1. How to go about finding the area of the mesh triangles in the first place? I know how to calculate the area of a triangle given three points in space, but according to the documentation, Sprite.triangles is a ushort[] that "contains indices into the vertex array", and I'm not sure how to deal with that. 2. How costly would it be in terms of performance to do this calculation in Update? \$\endgroup\$ Commented Nov 12, 2024 at 1:02
  • \$\begingroup\$ We have prior Q&A about how to calculate the area of a triangle mesh (and simplifications in 2D). Don't do it in update. If your sprite is changing size every frame, it's probably doing so via localScale, and you can just apply that as a multiplier rather than recomputing the area from scratch. If the area is changing because you're animating through a sequence of sprites, it would be better to cache the area of each sprite and look it up from a table based on the current frame. \$\endgroup\$ Commented Nov 12, 2024 at 2:53

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.