ScriptableObject Variable

Forums 💬 NodeCanvas 🤩 Custom Nodes and Tasks ScriptableObject Variable

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #12835
    aronze
    Participant

      Hi,

      In Unite 2017, Unity introduce about data oriented programming. Of course, NodeCanvas already run as similar. Anyway, first let to see this code:

      My idea is a very simple. I want to bind my float variable(ScriptableObject) to Blackboard Variable as primitive float. If it is possible, we can use existing actions like MecanimSetFloat.

      I’m digging BBParameter and ScriptControl actions mechanism but if you’re also interesting about this, I want to hear your advice.

      Thanks.

      #12841
      Gavalakis
      Keymaster

        Hey,

        Hmm. I am not sure I completely understand what you mean 🙂
        Can you please clarify? What do you mean by saying “scriptable object float variable” for example?

        Thank you.

        #12840
        wanderfalke
        Participant

          We created something like this for our project. The whole thing was added a little hacky and there is definitely room for improvements 😉
          I added an excerpt of our git patch file containing the changes made to node canvas. (The patch will most likely not work on your project but I think you’ll get the idea from reading it)

          Example usage:
          [CreateAssetMenu(fileName = “new_FloatReference”, menuName = “VariableRefs/Float”)]
          public class FloatRef : VariableRef<float>
          {
          }

          The scriptable objects can then be selected from nodecanvas when selecting a variable.

          #12839
          aronze
          Participant

            Thanks for share your code, @wanderfalke. Yes, my idea is exactly same.

            For example, create New Float asset for character health value. This asset used in game logic, health gauge, health text.  See following image:

            [attachment file=”Example.png”]

            This approach is very powerful. Variable asset easily can be use anywhere even out of scene. If you want more, see this link (Unity Documents).

            Finally, I think about following scenario:

            1. Create FSMOwner, Blackboard to my character object.
            2. Create Blackboard variable and link VariableFloat.
            3. If detect collision, decrease VariableFloat.

            In step 3, I want to use just NodeCanvas.Tasks.Actions.SetFloat. I don’t want to create new actions. BBParameter already have binding feature. So I think it can be.

            #12838
            aronze
            Participant

              I was found two way for this without modify NodeCanvas code. First way is implement that CustomConverter in TypeConverter. Second way, implement to IConvertible interface. All cases are work fine. Thank you.

              #12837
              aronze
              Participant

                I’m done this work but I can’t find way without modify NodeCanvas.

                [attachment file=”ScreenShot_VariableRef.png”]

                I can’t use CustomConverter, because GetSetConverter. See Patch_VariableRef.cs(zip)

                #12836
                elefantopia
                Participant

                  I use scriptable object to exchange data globally or as setup container.

                  What do you use this for @aronze?

                Viewing 7 posts - 1 through 7 (of 7 total)
                • You must be logged in to reply to this topic.