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.
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?
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.
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:
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:
Create FSMOwner, Blackboard to my character object.
Create Blackboard variable and link VariableFloat.
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.
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.