I'm trying to create an ability that pushes the target back in grid combat. Not sure if I am handling it the right way and I have some issues.
I added a schematic to the "battle animation" of the ability. In this schematic I use a status value that determines how many squares it will push. Then I go through a loop equal to this amount of squares where I check if the square behind the target is blocked, otherwise push the target.
But it seems like the loop only goes through it once and the push does not work even if there is nothing blocking behind it. Could be that I setup the loop wrong. Have not used them yet. And checking the blocked squares might be done wrong. Right now I select a square behind the target with a Battle Range Template.
https://ibb.co/LNSS1Nf
In short, the Loop node needs to be used in a loop of nodes. It'll be repeated as long as it's counter condition is valid.
Also, don't forget to use a Set Grid Cell Combatant node after a push to set the combatant as the Combatant of the cell.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I had the Set Grid Cell Combatant node when the loop is finished, or should I update the grid cell after each loop?
The Set Grid Cell Combatant node should be used in each loop to update cell occupations. Might not be needed in every setup (depending on the battle system and it's setup), but it's a good practice to keep this up to date with current positions in case you break out of the loop somewhere without setting the cell's occupant, leading to wrong placements.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
And thanks for the explanation of the Set Grid Cell Combatant.
I'm still stuck with with some things though:
1. I am not sure how to get the cells behind the to check if they are blocked. I have not succeeded in getting the target of the ability in general. Is there a trick to it?
2. Moving the target runs into the same problem. I am not sure how to get the target of the ability. The second problem is that I am not sure how to push them exactly 1 cell. I looked at how movement works, so I took the Change Position node but that only allows the target to move for a specific time or speed. I am not sure how to translate that to cells.
I responded to him on the Unofficial discord ;)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sorry for the long wait but I thought it would be nice to give an update for anyone that stumbles on this thread.
We ended up making a custom schematic node for pushing/pulling that will calculate which cell to put the target in. The node has a toggle to define if it is pulling or pushing
The rest of the schematic takes care of moving the target. If the target hits an obstacle or another combatant on the way, it will stop. It uses the Bresenham line algorithm to find the cells between two cells to check.
I have added a link where you can see the code.
https://dotnetfiddle.net/LA1zR4
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!