When I use Check or Change Variable node to Check or Change Variable on a spawned prefabs does I always have to store it in like "Selected data" for example and only then I can Check or Change Variable in that spawned prefabs?
Or I can also change it via select 'Game Object/prefabs'.

I ask this question because I can not Check or Change Variable via select 'Game Object/prefabs'.
So just to be sure this is not a bug and I just do it wrong!
  • Variables on a prefab require an Object Variables component on the prefab - which can be accessed via the Object variable origin.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ummm! You misunderstand my point! That is not what I mean!
    Sorry for didn't say it clearly enough because English is not my native.

    What I mean is when I use the "Spawn prefabs" node there is an option to store that prefabs data into the "Selected data".
    Does it require me to store that prefabs into the "Selected data" first before I can use it in the "Check/Change Variable" node or not?
  • No, it doesn't require that, since you can also access the prefabs through the object selection directly.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Then I think it a bug!
    Because I can't check or change the variable that prefabs though the object selection directly.
    So I have to store it in "Selected data" to be able to use it!
  • Does the prefab have an Object Variables component attached?
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Yes, it does!
    And on that 'Object variables' I'm not set any variables for it.
    And when I check for variable I uncheck the option 'Exists'
  • Tested it and it definitely works :)
    Make sure you're using the Object variable origin when accessing the spawned prefab's variables.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I know what you think and talk about. And yes I am sure I use that.

    Hmm! I think I know something is wrong!
    When I spawn an object then change its variable it working.
    But when I use the Input key to check and change the variable is not working.

    Are you try to test it with this? Spawn an object then change it variable, it works as you expected.
    But when you use the input key like "Mouse" to check and change it variable every fixed frame, then it not work.
    Why is that?

    I will attach my schematic here if you want to take a look to see what did I do wrong.
    https://drive.google.com/file/d/17hLqF7sooFOcPgRsmPeY-mG_fs7M57nr/view?usp=sharing
  • I've checked your schematic and I think I know what your issue is :)

    Disable Clear Prefabs in your schematic's Settings node. If it's enabled, the references to spawned prefabs will be removed when running the schematic again, and since your Spawn Prefab node isn't used in the node chain before accessing the variables there's no chance it can ever be used.

    That's why using selected data worked, because that isn't cleared in your setup.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Oh! So that why the prefabs not working!
    Thank! I didn't even look into that setting :D
Sign In or Register to comment.