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
  • You need to connect back to the Loop node after the push stuff - otherwise there is no loop for your loop :)
    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.
    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 okay, was not sure about that part. I did try it out with it looping back but it would still only go through the loop once even if the counter condition shouldn't be valid yet. Do I also need to increment the "counter" myself or does the loop node do that?

    I had the Set Grid Cell Combatant node when the loop is finished, or should I update the grid cell after each loop?

    image
  • The Loop node handles increasing the count for you - it basically replaces using a Change Variables and Check Variables node to handle this in one step. So, the Change Variable node in that schematic should be removed as it messes with the counter.

    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.
    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!
  • edited April 3
    Ah, then I'll remove the Change Variables node.

    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.

    image
    Post edited by Jasper on
  • Hello GIL =)

    I responded to him on the Unofficial discord ;)
  • Alright, let me know if anything is still needed :)
    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!
  • edited April 3
    Thank you both for all the help!

    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

    image
    Post edited by Jasper on
  • Good work and thanks for sharing your custom node :)
    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.