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.

Bug Unity changes subraphs to others at random when using prefabs.

Discussion in 'Visual Scripting' started by genryuu111, Jul 22, 2022.

  1. genryuu111

    genryuu111

    Joined:
    Aug 29, 2019
    Posts:
    2
    Hello, first time posting here, and for the record, I just started one month ago using Unity, and since I have no coding background, I've been using Visual Scripting.
    It's a tool I'm having fun with, and I find it often intuitive.

    But, I've been having this bug that is preventing me to proceed smoothly with my project.

    I have some prefabs, and some of them are loaded directly into the scene.
    I'm using several subgraphs.
    When I take a prefab (in this case, an enemy) into the scene, no issue. But once I run the game, sometimes (not always, and not necessarily in the same place) a subgraph will be changed to another one in the enemy in the scene. It will remain changed even after quitting the game. The prefab stays as it's meant to, but I need to delete the enemy from the scene and put it back.
    And, more often than not, it will do the same thing again.

    I'm pretty sure it's a bug and not an intended thing. I wonder if it's a known thing? Is there anything I can do to prevent this?
    I started the project on 2021.3.4f1 and I have updated to 2021.3.6f1. The issue has been there in both versions.

    I'll upload a picture to compare what the prefab looks like and what the enemy's script graph looks like once the bug occurs. unity bug.png
     
  2. ncr100

    ncr100

    Joined:
    Jul 23, 2015
    Posts:
    22
    Hi, congrats on making progress with Unity - visual scripting is a good way to go, IMO.

    I don't know the answer, off the top of my head. I am curious to learn more:

    > subgraph will be changed to another one in the enemy in the scene. It will remain changed even after quitting the game. The prefab stays as it's meant to, but I need to delete the enemy from the scene and put it back

    To clarify, please tell me if I am wrong:

    1 you have a Visual Script with multiple Subgraphs, let's call them "A", "B", and "C".
    2 you have A -> B
    3 you Play the scene
    4 you see the Subgraph change, in the Visual Script itself, to A -> C
    4 you un-click the Play button, to fully stop the player
    5 you see A -> C after you have stopped

    Is this a wrong understanding?
     
  3. genryuu111

    genryuu111

    Joined:
    Aug 29, 2019
    Posts:
    2
    Hey, thanks for the reply!

    Yes, that's what happens, keeping in mind that it's an instance of a prefab directly in the scene, the original prefab remains untouched.

    For now, I "solved" it by not having stuff in the scene, lol.
    Or actually, for some reason this would only happen with enemies, never with the player, never with anything else in the scene.
    Once I started instancing stuff from prefabs during runtime (instead of having them directly in the scene) I've never had the problem again. Which is not an ideal situation, so if there's a solution I'd still like to know ahah
     
  4. ncr100

    ncr100

    Joined:
    Jul 23, 2015
    Posts:
    22
    :) On one hand it's cool you found a way to make Visual Scripting change its own code. I joke: you created AI, it has a self-modifying structure, and I wonder what its children will be capable of.

    On the other hand, ouch painful to instantiate every object at runtime. That should not be necessary.

    Maybe there is a way we can isolate the buggy behavior, (bisect the conditions that cause the bug), because I assume your situation is not normal.

    Which visual scripting package are you using? 2021.3.6f1 is the Unity Version, and I think 1.7.8 is the newest VS package.
     
  5. literacy

    literacy

    Joined:
    Nov 14, 2021
    Posts:
    35
    << Once I started instancing stuff from prefabs during runtime (instead of having them directly in the scene) I've never had the problem again. Which is not an ideal situation, so if there's a solution I'd still like to know ahah >>

    This is actually how I get all of my Prefabs into my scenes. I have a Generator GameObject that upon runtime, creates instances of all the Prefabs that I need right away.

    Like mentioned it can be tricky sometimes because the Prefab isn't in the Scene yet... so there are certain things that I couldn't easily do (like say, reference the GameObject by name in another GameObject in the Scene). But once I committed to this approach, I found I was able to do everything that I wanted with a bit of planning! (i.e. I tag all my Prefabs and just use Find by Tag, etc.)
     
    ncr100 likes this.
  6. MatL

    MatL

    Joined:
    Jan 29, 2014
    Posts:
    43