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. Dismiss Notice

Question Any clues to what could make the first and only the first instance of a vfx fail to play?

Discussion in 'Visual Effect Graph' started by Meta_Bird, Sep 13, 2023.

  1. Meta_Bird

    Meta_Bird

    Joined:
    Apr 25, 2020
    Posts:
    15
    Hi,

    I have a visual effect setup on a prefab that gets instantiated during play (specifically, it is on a prefab that was then attached as a child game object to another prefab).

    I'm finding that the vfx consistently fails to play the first time the prefab is instantiated in the scene. But every time the same prefab is instantiated after that it plays without issue.


    If the scene loads with an instance of the vfx in the scene, the first time the prefab is instantiated it does then work without issue. Other variants of the prefab work without issue (every time) so this leads me to think the issue is not with the vfx itself but something about how the prefab is set up but I can't seem to find any differences between the variants.

    I'm using VFX graph with a single burst spawn system in constant spawn mode.

    Do you have any ideas on what settings could be driving this behaviour? Any tips on what to check would be much appreciated.

    Thanks!

    upload_2023-9-13_15-52-48.png
     

    Attached Files:

  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    This is not probably the case, but when you load asset for the very first time it might need to be compiled and in result there might be lag or vfx with cyan color or invisible. However I think this should happen for the first time you load the asset after start of unity, not every time you press playmode.

    I think developers will help you, but meantime you could try creating different prefab and see if the same happens or see if this happens if you disable instancing (the checkbox you can see on your screenshot).
    Also do you use addressables by any chance?
     
  3. Meta_Bird

    Meta_Bird

    Joined:
    Apr 25, 2020
    Posts:
    15
    Thanks @Qriva! I think you are right about this being a loading/compiling issue. As you say, when I look closely I do sometimes see some cyan particles spawning ... at least for a a very brief moment and then disappearing.

    I am using addressables. What confuses me is that I am using the exact same code to load and instantiate 10 different prefabs with the vfx attached and 2 have this problem and 8 do not (including when they are the first instance of the vfx in the scene).

    I have messed around with the instancing setting. With Allow Instancing off on the problematic prefabs, the vfx never renders / plays on any of the instantiated prefabs. With Allow Instancing off on the working prefabs the vfx always plays.
     
  4. gabriel-delacruz

    gabriel-delacruz

    Unity Technologies

    Joined:
    May 19, 2021
    Posts:
    31
    Hello!
    Would it be possible to have a simple project that reproduces the issue?
    You can post it here, or even better, report a bug so you can follow up.
    Thank you!
     
  5. Meta_Bird

    Meta_Bird

    Joined:
    Apr 25, 2020
    Posts:
    15
    Hi @gabriel-delacruz,
    Sorry, it was my mistake not a bug.
    I finally found a script on the parent prefabs with GetComponentsInChildren<Renderer>() that was interfering with the particle system's renderer, causing the problem.
    Thanks!