Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Custom variable scoping

Discussion in 'Visual Scripting' started by emrys90, Feb 11, 2021.

  1. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Is it possible to define a new scope for variables, or change how another works? I have a battle system and I'd like variables that are scoped to that. There are multiple battle systems in a scene, so Scene/App variables wouldn't work for it
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,050
    That's not possible natively at this time.

    A temporary workaround would be to use scene/app variables that reference a scene GameObject which then holds object scope variables necessary for a battle system. You can have as many game objects with object variables as necessary.

    Another would be to hold variables in C# scripts that you can then get/set in Bolt.

    And if you're proficient with C# then Bolt's source code does ship in Install Bolt folder of the asset store download or in Unity 2021 as a package.
     
    Last edited: Feb 11, 2021
  3. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Okay, thank you