News Forums RAIN General Discussion and Troubleshooting Unable to load custom actions when setting new behavior tree to a mind

This topic contains 8 replies, has 5 voices, and was last updated by  chirpytime 9 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #5249

    Fox
    Participant

    Hi, I’m having an issue using Custom RAINActions. Whenever I try to set a new behavior tree to the Agent’s Mind, I get warnings and exceptions. Here’s the detailed info:

    The code I’m running is
    mind.SetBehavior(btAsset, new List<BTAssetBinding>());

    where mind is a BasicMind, btAsset is a reference to the Asset of the behavior tree I want to switch to.
    Whenever this code runs, I get the following:

    Error on RAIN.Action.LoadActionInstance(String, String, Assembly):
    Unable to load custom action: CustomActionName

    Warning on RAIN.BehaviorTrees.BTLoader:LoadNode(ObjectElement, List`1, Assembly):
    Failed to load Behavior Tree:
    Object reference not set to an instance of an object

    My custom actions have the [RAINAction] attribute and they appear on the behavior tree editor, so I can’t understand what is wrong in the actions. The custom actions that appear in the errors are the ones that the new behavior tree contains in its nodes.

    • This topic was modified 1 year, 7 months ago by  Fox.
    #5254

    Aaron Mueller
    Participant

    @Fox,
    I had some similar problems in my project after updating from RAIN{indie} to RAIN 2.0.5.
    -
    For some reason, I had a problem in my code that didn’t cause a compilation error, but it did cause the “Custom Action” to fail to load, similar to how you mentioned above.
    -
    I think I posted about it here:
    -
    http://rivaltheory.com/forums/topic/upgrade-paths-rain-beta-to-rain-2-0/
    -
    Maybe you are seeing something similar and the code change I made will help you?

    • This reply was modified 1 year, 7 months ago by  Aaron Mueller.
    #5300

    Fox
    Participant

    Thanks for the reply! I actually saw your post before, but somehow missed part of the solution. I solved this by starting a Coroutine where I put the major part of the code that was inside the custom action. This code was making modifications to the AI / Behavior Tree.

    However, it only solved some of the errors. There are still custom actions that fail to load when I call BasicMind.AIInit() after changing the behaviour tree. I’ve changed some of the custom actions to a single line of code

    return ActionResult.SUCCESS;

    and they still fail to load.

    • This reply was modified 1 year, 7 months ago by  Fox.
    • This reply was modified 1 year, 7 months ago by  Fox.
    #5316

    prime
    Keymaster

    We can take a look if you have a project you can share.

    #5342

    Fox
    Participant

    The “unable to load custom action” error was solved by removing the “using project.namespace;” instructions and replacing it with the classes with the full namespace path each time they were used, like this: project.namespace.Class ohHaiThere;

    Will you be able to fix this problem in a future patch? Or do we have to be careful from now on when using multiple namespaces?

    #5428

    NPC
    Participant

    I’m working with Fox, and after some tests, it appears the problem isn’t solved solely from clearing usings.
    There is a custom RAINAction that is being loaded and is working in one behaviour tree, but triggers an “Unable to load custom action: (..)” in another tree when trying to load it during runtime.
    They are both being loaded at runtime.
    Any idea what might trigger this error?
    How can I know more about it?
    Unable to load custom action: xx isn’t very helpful.

    #5479

    prime
    Keymaster

    I don’t know why one attempt would succeed and another would fail. Loading a custom action involves scanning the loaded assemblies to try to find a match. Only classes that have the [RAINAction] attribute are considered.

    It is possible that the behavior tree could get out of sync, for instance if you are using namespaces and they change. To resolve it, you might need to find the custom action that is failing, set it to a different custom action, wait for the BT to save itself, and then set it back to the correct action again.

    If that doesn’t work, then I’m going to need to find a way to reproduce the problem so we can track it down.

    #5561

    NPC
    Participant

    Resetting the custom action did the trick.
    Thank you prime.

    #33410

    chirpytime
    Participant

    Thanks! I was playing with RAIN 2.1.3 QuickStart project and had the same issue. I had auto-compile off, created a custom action from the behavior editor, and then back to editor, manual refresh. No compilation error, but assembly error.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.