Thank you so much for helping @PrayWaits, [USER=“641905”]leo bar[/USER]! Great explanation where I have no objections. As for your comments, @PrayWaits on this seeming a bit unnecessarily complicated, I can understand and thought I should give a bit of an explanation (I’ve tried to communicate the same thoughts in my Action System tutorials):
Say you did this the simple way instead. Instead of going through all the trouble of passing the NuberOfAttacks variable through various QueueAction macros, why not for example just get a reference to the owning actor in your animation blueprint and getting the NumberOfAttacks straight from there? Well, first there is the replication thing. If you are making a multiplayer game you would then have to make sure to replicate every variable you want to use in this fashion, which is normally taken care of automatically by the action system, but this is not that big of a deal. Also, if you’re making a single player game, why should you care?
The larger problem is the fact that the server-side stuff and when stuff is animated does not happen simultaneously. For example, on an AI unit’s turn it might move to a tile, attack a unit and end its turn. In the game logic (and server side) this all happens instantaneously, in the same tick. As part of this many animations are queued. This would be activation of the unit, moving to a location, playing an attack animation, subtracting health from the health bar and then showing the selection of a new unit. If none of the variables used for the animations have changed between queuing the action and actually getting around to animation the action there is no issue. If they have we have a problem, however.
Say that you have an ability that increases NumberOfAttacks for this turn, which ends at the end of the turn. In the game logic you set NumberOfAttacks to 2, deal damage twice, end the unit’s turn and set number of attacks back to 1. After all of this is done, the walk animation before the attack just started animating. By the time the attack animation happend NumberOfAttacks is back to 1, so getting this directly from the unit in its current state will get the incorrect value. Now suddenly health has been reduced twice in the game logic, but just once when animating. This will result in all sorts of strange behavior like the unit dying and becoming unselectable, but the unit still standing there animating with a non-empty health bar. This stuff becomes an even larger problem in multiplayer, where latency can cause things to animate at different times for different clients (an added benefit of the action system in multiplayer is that there should never be visible lag for clients, since animations and actor locations are not replicated continuously).
So, as long as you are making a single player game and can be 100% sure that the variable you are using for animating does not change from when it was used for game logic it is possible to get a reference directly instead of passing it through actions. Using actions is safer, though, so I would recommend using them whenever it is not highly impractical. The specific thing you are trying to modify is probably the most complicated use of the action system in this toolkit and normally it will be much more straightforward.
Hope this explanation helps you understand this better.
Hi, @xermao. I’m not sure I understand what you mean. Can you describe in a bit more detail? Are you thinking of something like the player clicking and enemy and then having the unit both move and attack automatically in sequence?