edited March 2021 in ORK Support
I downloaded the sample AccessHandler scripts, and then I set the Game/Game Settings/Base Settings/Access Type to "Custom". I then added a Debug.Log("Test"); line to CombatantAccessHandler.CreateInstance method. However, I noticed that when the game start event created my player combatant, the log isn't being logged. The player is spawned in the scene.

Is there something else I must do to set up the AccessHandler?
Post edited by Flying_Banana on
  • There are 2 CreateInstance functions, one for the default init (using the combatant's start level, etc.) and one more detailed with more parameters, which is used by most combatant creations in ORK.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • That solved half of the mystery! Now my player (spawned via ORK events) is now printing the log, but I noticed that if I instantiate a Combatant via script like so:
    Group group = new Group(unit.FactionId);
    Combatant combatant = ORK.Combatants.Create(unit.CombatantId, group, false, false);
    combatant.Init();
    GameObject combatantObject = combatant.Object.Spawn(Vector3.zero, false, 0, false, Vector3.one);
    Then the access handler won't get invoked. Is this intended? If so, is there a way to ensure whatever I put in the CombatAccessHandler will be called from both ORK events and custom script?
  • That's the function the access handler calls to create the combatant - you can call whatever function suits you. The access handler is there to route all calls of ORK functionality through a central class to make it possible to inject your custom functionality there without having to make changes throughout the framework (and having to recompile the code).

    If you don't need to do that, you can just call ORK.Combatants.Create directly, or go through the access handler - doesn't matter much :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ah, so in my script, if I have a custom AccessHandler, I should call Create there instead of using ORK?
  • Yeah, either call ORK.Combatants.Create or the base implementation of the access handler, which does that (i.e. base.CreateInstance).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.