edited January 23 in ORK Scripting
Hello @gamingislove, I would like to set the player enemy target right away when starting the battle (right now they are set after triggering an ability via control map auto target) meaning there's no target autoselected before that.
There's a SetTarget(Combatant) method in the BaseAction class but I can't find how to access it from the executed Action (Ability) Control Map. How can this be achieved?
Post edited by RustedGames on
  • Check out the group/individual targets - found in Battle System > Target Settings in ORK 2.

    Group targets are for group-wide targets, individual for an individual combatant. They can also auto select the nearest, beside using input keys and click/touch to select targets.
    Using actions on them requires your control map keys (or battle menu) to also enable using group/individual targets.
    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!
  • Hi @gamingislove
    The help description for the Target Settings->Individual Target Settings was confusing to me:
    "Individual targets are only available to the combatant who selected them" but after playing with the settings at first wasn't working.

    Here's the screenshot of the settings:
    image

    I added also a Target cursor to have a visual feedback, then when starting the battle the enemy from Lightning's left is selected with cursor (I' assuming that's the target from above settings, but when activating the ability the other enemy is affected?

    image

    Then went back to the Control Map and enabled the "Use Individual Target" and that did the trick,

    image


    however from code I can only query the ORK.Game.ActiveGroup.Leader.Battle.LastTargets list, is there a way to get the current target so I can pass it to the Camera Target Group list?
  • They're available via the SelectedTargets property of a combatant (i.e. individual targets):
    ORK.Game.ActiveGroup.Leader.SelectedTargets

    Or a group (i.e. group targets):
    ORK.Game.ActiveGroup.SelectedTargets

    Both use the same underlying class, so access to the targets works the same for both, e.g. for the first added group/individual target selection:
    Combatant target = combatant.SelectedTargets[0];
    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!
  • I'm still getting this weird behavior shown on the screen above, where an enemy is auto selected at the start of the battle, but the ability is applied to other enemy instead.
  • Try disabling Use Auto Target in the control map key, that might be overruling it. Also, since I can't see it - I assume you set up the target settings in the individual targets, not group targets, otherwise also enable Use Group Targets in the control map key (doesn't do harm if no group targets are set up anyway).
    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!
  • Thanks GiL, now it is working as it should, and showcased it in my lasts videos ;)
  • I am also trying to get the selected target for a combatant. I read this thread and made this method:

    public Vector3 GetCombatantTargetPosition(GameObject combatantObject)
    {
    if (ORKComponentHelper.GetCombatant(combatantObject) != null)
    {
    Combatant combatant = ORKComponentHelper.GetCombatant(combatantObject);
    Combatant target = combatant.SelectedTargets[0];
    return target.Object.GameObject.transform.position;
    }
    return Vector3.zero; // Just for debugging
    }

    But when using the Player gameObject as argument, I keep getting back the player position instead of its target's position :(
    My Control Maps Inputs (Shortcuts) are set to use both Group and Individual targets.
  • edited February 7
    @ChimpLogik what's the outcome if you pass an ActiveGroup Leader instead a plain combatant?
    Post edited by RustedGames on
  • @gamingislove may I request the addition of an Event to register with when a target has changed to let other system know about it. For sure I can achieve it modifying the source code, but a good example will be on the SelectedTarget class where we get the selected target at group or individual level:
    public Combatant this[int index]
    I saw this two methods, when group targeting
    this.ownerGroup.FireAfterTargetChange();
    and when individual targeting
    this.owner.UI.FireAfterTargetChange();
    and passing the selected object in the event

  • @ChimpLogik
    The SelectedTargets of combatants/groups are for the Individual/Group Target Settings in Battles > Target Settings, are you using those?
    And does your combatant have the individual target selected?

    @RustedGames
    The combatant already has event handlers to register for that, but they're in the UI part:
    combatant.UI.BeforeTargetChange += notify;
    combatant.UI.AfterTargetChange += notify;

    notify is a function without parameters.
    Naturally, before is fired before the target change is done (i.e. accessing the targets here will give you the old targets), after is after the target change was done (i.e. accessing the targets here will give you the new targets).
    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's great I thought those were bound to the use UI target menus only
  • @gamingislove when switching between schemas (they are different combatants in the player group) I would like to assign the target the previous schema had if its the same, currently the target is reset, this is steps I'm doing when swapping schemata.
    1) hold a reference of the current schema
    2) Set the Gameobject of the new schema to active
    2) Set active leader to the new schema and assign it to the reference above
    3) Deactivate GameObject to the previous schema to hide it from the scene
  • I restarted Unity today and Combatant target = combatant.SelectedTargets[0]
    was returning the correct target. How strange...
    PS: ORK.Game.ActiveGroup.Leader.SelectedTargets was also working and returning the correct target :)
  • @RustedGames
    If you're only have one combatant in battle at a time, you could just use group targets instead of individual targets (accessed via the combatant's group, i.e. combatant.Group.SelectedTargets).
    Depending on how you switch, you can either handle this via custom scripts or schematics - in schematics, you can store the target before the change via a Select Combatant node, which let's you also get individual/group targets.
    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.