Search Unity

Question ScriptMachine inside a ScriptableObject. Can't "get" variables.

Discussion in 'Visual Scripting' started by Creiz, Dec 15, 2022.

  1. Creiz

    Creiz

    Joined:
    Jun 6, 2017
    Posts:
    130
    I'm a ***very*** lousy programmer. Which is why I'm using Visual Scripting. If I knew how to code, I would be coding instead. But I don't, so I use Visual Scripting.

    With that said, thing are going pretty well for the most part, except I'm in a bit of a stumble, here. I can't figure out how to proceed for this next part.

    I'm trying to make an ability system that fires at every turn. However I can't change anything in it.

    I have this ScriptableObject:

    Unity_BnqXTkB43G.png

    How do I get the Script Graph Asset reference and trigger a custom event inside it?

    CustomEvent.Trigger wants a "GameObject".

    And doing var AssetObject = _assetGraph.GameObject() just give zero results. It does nothing at all.

    Actually neither does trying to change any variables on these. The turns don't decrease, either.

    Some help, please?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,068
    Graph Asset logic, including Custom Events, can't be executed without ScriptMachine Monobehaviour.

    You could instantiate a fresh GameObject, add ScriptMachine component to it, then set the graph on the ScriptMachine using the reference from SO, then trigger the custom event on the Instantiated GameObject.

    What you're attempting is a data driven workflow which current VS does not support by default. They intend to support that type of workflow in the next major version of the tool in 2-3 years.

    Scriptable Object itself should be freely accessible get/set wise if you've added it to Node Library in Project Settings and regenerated nodes.
     
    Last edited: Dec 15, 2022
    Creiz likes this.