Back again with another trigger issue.
I am trying to make a trigger that selects units on the battlefield with the arrow keys.
What i am creating is a turn based combat system, and you select the target for attacks/abilities with the arrow keys.
When a unit is selected i create an actor overhead (arrow pointer) to visualize which target is selected.
The system works for the most part, however i have one issue with the selection.
To try to visualize the battlefield:
E1 E2 E3
E4 E5
P1 P2 P3
E is enemy unit, P is player unit.
If i select P1, then press right arrow key to select P2 that works, but when i press right arrow key again, P3 will not be selected.
This issue is the same with both left and right, it manages to jump 1 step left or right, but then it gets stuck.
The trigger is fairly large, so ill post a part of it here:
This is the part of the trigger controlling pressing left if the current selected unit is 2 (Players Battle Units[2])
The rest of the trigger looks pretty much the same for every other unit, so 7 of these for left pressing, 7 for right, as there can be a total of 7 units on the field at one time.
The reason i have 3 different Else Ifs is if the unit to the left of the current unit is dead, it should instead select the one left the dead unit. And if all other units are dead, it should stay selected on the current unit.
So this above part works once, so it will jump from CurrentSelected 2 to Current Selected 1, but then it stops working, so it will not jump from Current Selected 1 to CurrentSelected 0 on the next press of the left arrow key.
OwnerofSelected is if its currently on friendly or enemy unit, 1 is friendly, 2 is enemy.
CurrentSelected is the currently selected unit.
This is my first attempt at creating something like this.
There is probably a much easier/cleaner way to make this work, through library or similar. Please feel free to leave suggestions.
EDIT: As a side note, does a local variable keep its value from last execution of a trigger or will it be its default value the next time the trigger is run?
Actually, found the issue.
It was the question i had last that was the issue, as the CurrentSelect and OwnerofSelect was local variables they reset every time the trigger was run, thereby it "restarts" the selection.
Changed them to global variables and now it works flawlessly :)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello!
Back again with another trigger issue. I am trying to make a trigger that selects units on the battlefield with the arrow keys.
What i am creating is a turn based combat system, and you select the target for attacks/abilities with the arrow keys.
When a unit is selected i create an actor overhead (arrow pointer) to visualize which target is selected.
The system works for the most part, however i have one issue with the selection.
To try to visualize the battlefield:
E1 E2 E3 E4 E5
P1 P2 P3
E is enemy unit, P is player unit.
If i select P1, then press right arrow key to select P2 that works, but when i press right arrow key again, P3 will not be selected. This issue is the same with both left and right, it manages to jump 1 step left or right, but then it gets stuck.
The trigger is fairly large, so ill post a part of it here:
This is the part of the trigger controlling pressing left if the current selected unit is 2 (Players Battle Units[2]) The rest of the trigger looks pretty much the same for every other unit, so 7 of these for left pressing, 7 for right, as there can be a total of 7 units on the field at one time.
The reason i have 3 different Else Ifs is if the unit to the left of the current unit is dead, it should instead select the one left the dead unit. And if all other units are dead, it should stay selected on the current unit.
So this above part works once, so it will jump from CurrentSelected 2 to Current Selected 1, but then it stops working, so it will not jump from Current Selected 1 to CurrentSelected 0 on the next press of the left arrow key.
OwnerofSelected is if its currently on friendly or enemy unit, 1 is friendly, 2 is enemy. CurrentSelected is the currently selected unit.
This is my first attempt at creating something like this. There is probably a much easier/cleaner way to make this work, through library or similar. Please feel free to leave suggestions.
EDIT: As a side note, does a local variable keep its value from last execution of a trigger or will it be its default value the next time the trigger is run?
I'll look at the rest in a little bit but I'm pretty sure a local variable just means the other triggers can't see it.
Actually, found the issue. It was the question i had last that was the issue, as the CurrentSelect and OwnerofSelect was local variables they reset every time the trigger was run, thereby it "restarts" the selection. Changed them to global variables and now it works flawlessly :)