Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Manual particle emission, rotate the whole particle system

Discussion in 'General Graphics' started by CrovaxBG, Mar 28, 2023.

  1. CrovaxBG

    CrovaxBG

    Joined:
    May 28, 2016
    Posts:
    5
    I'm manually emitting particles from a particle system using Emit. It's supposed to replace multiple instances of the same component, so at once multiple (20-40) emit positions are being used like so:

    Code (CSharp):
    1. private IEnumerator EmitParticlesGradually(Vector3 spawnPos)
    2. {
    3.    yield return _wfs;
    4.  
    5.    var totalParticles = (int) (rateOverTime * emissionDuration);
    6.  
    7.    for (int i = 0; i < totalParticles; i++)
    8.    {
    9.        var randomPoint = (Random.insideUnitCircle * _shapeModule.radius);
    10.  
    11.        var position = spawnPos + new Vector3(randomPoint.x, Y, randomPoint.y);
    12.  
    13.        _combinedParticleSystem.Emit(new ParticleSystem.EmitParams {position = position}, 1);
    14.  
    15.        yield return _emissionInterval;
    16.    }
    17. }
    This coroutine is simultaneously started with different positions and it works fine as long as I don't need the whole thing rotated.

    The particles use Velocity over lifetime module for their movement, which is downwards and tilted on the horizontal side. When the emission happens the current camera rotation is being used to ensure the spawn angle is always the same regardless of where you're looking. However I cannot change the rotation of the particle system when I'm manually emitting particles since there are multiple instances and therefore multiple rotations are needed, making it jitter.

    In essence when using regular multiple instances of particle system I would just change the rotation of the holding transform, however this doesn't appear to be possible when using ParticleSystem.Emit(), what workaround are there?
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,281
  3. CrovaxBG

    CrovaxBG

    Joined:
    May 28, 2016
    Posts:
    5
    The rotation there is already set to 90 degrees on X, but changing it doesn't seem to help at all.