I'm new to ORK. I want to extend Combatant with some custom fields and behavior, and I'm wondering what's the best way to do this. For example, I want to store a field specifying which move speed type the combatant is currently using. I think I can use the local object variables for this, but then I need to add this variable to every single combatant I'm creating. This isn't great if I decide to add a new field after creating a hundred combatants, as I need to manually add the new variable to each existing combatant.
I'm thus thinking about adding a custom class to store these extra fields, and I'm wondering if this is the right way to go.
You can also blend them together, though. E.g. have a custom component on the prefabs and use it to set some default object variables on the combatant.
Check out this how-to on getting a game object's combatant. Once you've got the combatant, you can change the combatant's object variables like this:
combatant.Variables.Set(key, value);
key is a string, containing the variable key (e.g. moveSpeedType).
value can be a bool, float, string and Vector3 value you want to use.
There are also other functions available in the variable handler you access via combatant.Variables. And you don't even have to set up object variables in the combatant, as accessing it like this will automatically create variables on the combatant.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
After prodding the code some more, I think I also want to extend CombatantSetting, in addition to Combatant. That is, I also want every single instance of CombatantSetting in the editor to have extra fields, shared for all Combatant instances of that specific CombatantSetting instance. I think I can do this by unchecking local variable in the object variable section, but I'm wondering if it's also possible to automate this. Say if I create a new CombatantSetting in the ORK editor, is it possible to write a script to create the extra variables I need?
If you do it via object variables, you can only either use local (i.e. per combatant) or shared object variables via the Object ID.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Is it recommended at all to modify the DLL? Wouldn't it be overwritten when applying an upgrade?
If there's a custom feature you need and can't implement otherwise, go for the modified DLL and only update in case you need a bugfix or a new feature and re-implement your stuff. An alternative is to commission a feature and make it part of ORK's update cycle (i.e. everyone else would also get it).
As for object variables, yeah - you can either use them in a local mode (or with a unique object ID) or have everyone with the same object ID share the same variables. This isn't limited to combatants, e.g. if you set up an Object Variables component on a regular game object in your scene and use the same object ID as a combatant, it'll also share the same variables.
You can also use multiple object variable components, e.g. have the combatant's setup use local variables, but adding an object variable component to a child object of the combatant for some shared variables. That way you can access the shared variables via defining the child object (e.g. in Change Game Variables or Check Game Variables nodes).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!