Are there actually targets available? Maybe add a debug output to the target handling to see if any targets are added.
If the ability is useable in field (since the combatant isn't in battle) and has no use costs/conditions, that's the only other thing I can think of that prevents the use.
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!
There is the list of game objects Targets I am setting for the Use function . That list is not empty. abilityShortcut.Use(combatant, SetTargetCombatantsList(Targets), true);
private List<Combatant> SetTargetCombatantsList(List<GameObject> listObjects) { List<Combatant> targets = new List<Combatant>(); for (int i = 0; i < listObjects.Count; i++) { Combatant combatant = ORKComponentHelper.GetCombatant(listObjects[i]); if(combatant!=null) targets.Add(combatant); } return targets; }
But are there actual combatants added to the list? Did you try adding a debug output to see if the returned targets contain anything?
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!
Yes, I modified the code (below) and the Console print this: "The list of Combatant targets contains 1 element(s)"
but then I added a second function GetThisCombatantTargets() to obtain the targets directly from my AI combatant right after, and when checking for combatant.Actions.Current.target it gives a NullReferenceException :(
private void SetTargetCombatantsList(List<GameObject> listObjects) { Combatant thisCombatant = ORKComponentHelper.GetCombatant(this.gameObject); if(thisCombatant!=null) { List<Combatant> combatantTargets = new List<Combatant>(); for (int i = 0; i < listObjects.Count; i++) { Combatant combatant = ORKComponentHelper.GetCombatant(listObjects[i]); if(combatant!=null) combatantTargets .Add(combatant); }
Debug.Log("The list of Combatant targets contains " + combatantTargets .Count + " element(s)");
GetThisCombatantTargets(thisCombatant ); // NEW Check } }
public void GetThisCombatantTargets(Combatant combatant) { List<Combatant> combatantTargets = combatant.Actions.Current.target; //ERROR Line ******* Debug.Log("This combatant targets count now is: " + combatantTargets.Count); }
Alright ... in that case it might be a target that's not targetable or out of range of the ability.
As for the error - yeah, you try to access the current action without checking if there is a current action (i.e. it being null) first. I assume at this point (getting targets for the action) the action hasn't started yet, so there is no current action.
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!
After a lot of attempts switching parameters around I got it to work, but the reason why it is now functioning is not clear.
I had to change Ability> Target Selection Setting> Target Type from "Enemy" to "All". Strange thing is my attacker's faction is -or at least should be- an Enemy to the defender since the attacker-defender faction's sympathy is set to -1000 (on a scale of -1000 to 1000). That said, I didn't define the defender relationship to the attacker (since the defender's faction is passive).
Does the "Enemy" target Type need to be reciprocated to be considered, in fact, enemy by the attacker or leaving some of the combinations of faction-sympathies undefined creates issues?
If it's working with All and not with Enemy the targets you have selected are simply not enemies :)
A combatant is an enemy of another combatant if their factions have negative sympathy for each other.
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!
If the ability is useable in field (since the combatant isn't in battle) and has no use costs/conditions, that's the only other thing I can think of that prevents the use.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
abilityShortcut.Use(combatant, SetTargetCombatantsList(Targets), true);
private List<Combatant> SetTargetCombatantsList(List<GameObject> listObjects)
{
List<Combatant> targets = new List<Combatant>();
for (int i = 0; i < listObjects.Count; i++)
{
Combatant combatant = ORKComponentHelper.GetCombatant(listObjects[i]);
if(combatant!=null)
targets.Add(combatant);
}
return targets;
}
Perhaps I need to set that list somewhere else?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
"The list of Combatant targets contains 1 element(s)"
but then I added a second function GetThisCombatantTargets() to obtain the targets directly from my AI combatant right after, and when checking for combatant.Actions.Current.target it gives a NullReferenceException :(
private void SetTargetCombatantsList(List<GameObject> listObjects)
{
Combatant thisCombatant = ORKComponentHelper.GetCombatant(this.gameObject);
if(thisCombatant!=null)
{
List<Combatant> combatantTargets = new List<Combatant>();
for (int i = 0; i < listObjects.Count; i++)
{
Combatant combatant = ORKComponentHelper.GetCombatant(listObjects[i]);
if(combatant!=null)
combatantTargets .Add(combatant);
}
Debug.Log("The list of Combatant targets contains " + combatantTargets .Count + " element(s)");
GetThisCombatantTargets(thisCombatant ); // NEW Check
}
}
public void GetThisCombatantTargets(Combatant combatant)
{
List<Combatant> combatantTargets = combatant.Actions.Current.target; //ERROR Line *******
Debug.Log("This combatant targets count now is: " + combatantTargets.Count);
}
As for the error - yeah, you try to access the current action without checking if there is a current action (i.e. it being null) first.
I assume at this point (getting targets for the action) the action hasn't started yet, so there is no current action.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I had to change Ability> Target Selection Setting> Target Type from "Enemy" to "All".
Strange thing is my attacker's faction is -or at least should be- an Enemy to the defender since the attacker-defender faction's sympathy is set to -1000 (on a scale of -1000 to 1000).
That said, I didn't define the defender relationship to the attacker (since the defender's faction is passive).
Does the "Enemy" target Type need to be reciprocated to be considered, in fact, enemy by the attacker or leaving some of the combinations of faction-sympathies undefined creates issues?
A combatant is an enemy of another combatant if their factions have negative sympathy for each other.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!