Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Bug Particle system bounds lag behind causing particles to disappear

Discussion in 'General Graphics' started by xVergilx, Jan 19, 2021.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,490
    So when moving object that has a particle system set to shape (SkinnedMeshRenderer) bounds doesn't seems to catch up correctly:
    GIF.gif
    (Ignore actual frame drops, gizmos are too heavy to render)

    Actual particles are where they should be, but bounds really lag behind.
    Which causes particles to disapper in game (and also flicker), since culling kicks in and thinks that particles are offscreen.

    This is probably because object (model) is updated in LateUpdate;

    Setting culling mode to "Always Simulate" doesn't help (particles are simulated correctly though).
    Is there a way to disable particle system bounds culling completely?

    Setting simulation space to world does solve the issue, but breaks the effect unfortunately.
    SkinnedMeshRenderer has "Update while offscreen" enabled.

    Any other suggestions?
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    1,705
    I recommend submitting a bug report for that. It seems like a bug.
    You're probably correct that LateUpdate has something to do with it :)
     
    xVergilx likes this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,490
    Submitted. Case 1307534.

    Note that this bug is most likely framerate dependant.
    In repro project I had to ramp up movement speed quite high, but in my project it doesn't require that much.
     
    richardkettlewell likes this.
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,490
    Also, managed to create a hack that extends bounds of Particle System.
    If anyone encounters same issue, you can emit particles at max bounds of your scenes, and that will disable culling logic:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace FX {
    4.    public class ParticleBoundsHack : MonoBehaviour {
    5.       [SerializeField]
    6.       private ParticleSystem _ps = default;
    7.  
    8.       private void OnEnable() {
    9.          _ps.Emit(GenerateEmitParams(new Vector3(100000f, 100000f, 100000f)), 1);
    10.          _ps.Emit(GenerateEmitParams(new Vector3(-100000f, -100000f, -100000f)), 1);
    11.       }
    12.  
    13.       private ParticleSystem.EmitParams GenerateEmitParams(Vector3 pos) {
    14.          return new ParticleSystem.EmitParams
    15.                 {
    16.                    startSize = 0.01f,
    17.                    angularVelocity = 0,
    18.                    applyShapeToPosition = false,
    19.                    position = pos,
    20.                    startLifetime = float.PositiveInfinity,
    21.                 };
    22.       }
    23.  
    24. #if UNITY_EDITOR
    25.       protected virtual void OnValidate() {
    26.          _ps = GetComponent<ParticleSystem>();
    27.       }
    28. #endif
    29.    }
    30. }
    31.  
    Attach this script to particle system, and it should extend bounds to [-100000f; 100000f] min max points.
    If some extra properties used, EmitParams can be extended to anything required.
     
unityunity