Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Pooled Generic Particle Systems don't move their spawn position once played

Discussion in 'General Graphics' started by richard-firehose, Apr 25, 2023.

  1. richard-firehose

    richard-firehose

    Joined:
    May 31, 2019
    Posts:
    15
    Hello! I've got a pooling system for particle systems where the particle systems in the pool are generic, and then the data gets copied over from various prefab particles when we need a particle system. This all works great on particle systems that don't move while being played, but for some reason, the particle systems that have transforms that move around do not follow their transforms and instead stay in place where they were initially played from.

    So far I have tried:
    • Childing the pooled particle system to an empty transform and moving that transform around instead
    • Playing and Stopping the particle systems once after the particle has been removed from the pool and configured for use
    • Toggling on playOnAwake, turning off the game object, then on again, then toggling off playOnAwake
    • Doing all of these three things in combination
    I know that the particles move if they are instantiated as instances of a prefab, I'm not sure why this behavior seems to happen exclusively when they are being configured like this via a pool. I'd like to avoid pooling all the particles separately, as our game has a wide range of particle systems not always on screen and we want to keep the memory cost of the particle systems down.

    Does anyone know how to solve this problem? Thanks so much!
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,689
    richardkettlewell likes this.
  3. richard-firehose

    richard-firehose

    Joined:
    May 31, 2019
    Posts:
    15
    Sadly not, this is meant to apply to both world and local space particle systems. The issue is really for local space particle systems, I haven't tested out the world space particle systems (we use far fewer of those), but the local space issue is that once you hit play, the system stays fixed in place as the transform moves around on subsequent frames (including for new particles introduced). It's like some weird hybrid behavior that's half local space, half world space where the spawn position doesn't move because its local space, but the spawn position itself is treated as a world position rather than a local one and doesn't follow the transform. Hitting stop and playing again migrates the particle system spawn position to the new location, but then it's also stuck in place there.

    The thing is that before we were pooling the particle systems, the same prefab particle systems worked just fine when spawned as is (without doing what we do now, which is take a generic particle system, copy over all the module settings from a template prefab, nest the transforms as necessary from some baked data, and then have this new streamed in particle system follow some runtime matrix data). The transforms move as expected/follow the matrix data, but the local space particle systems just stay fixed in place once played now. There seems to just be some kind of internal/unexposed cached variable in Unity telling the particle not to move with the transform, but I have no idea what to do to reset that variable :/
     
    Last edited: Apr 26, 2023