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

Question Custom variable scoping

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

  1. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    752
    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:
    1,825
    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:
    752
    Okay, thank you