• August 5, 2016 at 15:47 #13395


    I’ve been using Apex Utility AI for two weeks or so and, while I really like it in theory, I’m just not able to find a few features mentioned on the website, the main one being utility curves — where can I select them?! I’ve searched the entire documentation, the forums, watched all the tutorials, but for some reason I just can’t find anything about one of the most important features. Could you point me in the right direction, please?


    • This topic was modified 1 year ago by Fabian.
    August 5, 2016 at 16:02 #13398

    Hey Fabian,

    (Animation) curves are primarily meant to be used in conjunction with qualifiers or scorers as input fields, which are then adjustable/tweakable from the Utility AI inspector.

    Basically you have two options for using animation curves in conjunction with the Apex Utility AI.

    1) There is a base class for Contextual Scorers, called “UtilityCurveEditorBaseScorer”, which adds an Animation curve field.

    2) Alternatively you can simply define your own AnimationCurve field on any AI entity, i.e.:

    • This reply was modified 1 year ago by Rami.
    August 5, 2016 at 16:52 #13401

    Ah, great, thanks!

    July 8, 2017 at 00:35 #21265

    Sorry to revive an old thread.

    @Rami I have found that if in my derived class from UtilityCurveEditorBaseScorer, I use the constructor to initialize the AnimationCurve, at some later stage the curve gets overriden by the one defined in the Unity APEX Editor.

    Debugging that, shows that the constructor is being effectively called, and the data is being set correctly. However later when Score() is called on the same class, the curve data is no more the one defined in the constructor.

    This is not just counterintuitive, as by the time my constructor ends, no extra changes should be done to my data, but also forces me to use some hackish workaround to re-initialize the curve data when Score() is called.

    Edit: is worth mentioning that I could also create my own version of “UtilityCurveEditorBaseScorer” and derive from that, but Im suspecting this has to do with ApexSerialization, so I could end up in the same situation. I need the curve visible in the editor, thus I would need to mark the curve field with [ApexSerialization]… so Im sort of trapped.

    Please advise :)
    Thanks in advance!

    • This reply was modified 1 month, 2 weeks ago by Novack.
    • This reply was modified 1 month, 2 weeks ago by Novack.
    July 10, 2017 at 10:16 #21290

    Hi Novack,

    The AI uses reflection to set up and initialize, and in that process it reads in the serialized value for the curve, overriding any set in the constructor. The intention was that you would tweak the curve using the AI Editor Inspector, rather than set it through code.

    If you truly want to set it through code, you will either need to use a separate variable that you can default to a custom curve, or a custom base class as you note yourself. The default value for the default curve editor is just a simple linear curve from 0 to 1, so that is serialized into the AI if nothing else has been set.

You must be logged in to reply to this topic.