Dodge distance and invincibility frames
Dodge animation and distance
After creating sprite animations for dodging, it was time to implement the action in the engine.
The direction, speed, and distance of the dodge are handled by a timeline event that applies velocity to the player pawn to the direction they're facing based on the directionality variable (which's main use is to determine the direction the sprite should be facing). However, since the values of the variable can only be 0 or 1, dodging in an intercardinal direction would make the dodge distance longer (shown with yellow lines in the picture below).
The fix was to use the forward vector of the directional arrow component I talked about in one of my earlier posts. When facing an intercardinal direction, the forward vector would give values of 0,77... for both the x and y axes which would then translate to the same distance as dodging in cardinal directions (shown in red in the picture below).
![]() |
| Dodge distances while using the directionality variable and D-arrow's forward vector. |
Below is also part of the blueprint that handles the dodging. The timeline event currently outputs a constant value of 1 for the dodge distance, which can be tweaked to slow or hasten movement during certain parts of the dodge. For example, the dodge could begin as a fast movement and then slow down toward the end.
![]() |
| The final blueprint for dodge distance and direction. |
Invincibility frames
As for invincibility frames (iFrames), I tried out a few different methods to implement them and see which one worked out the best. A boolean variable is used to check if iframes are on or off. Iframes should turn on on the third frame of the dodge animation and last until the 19th frame. Duration in seconds is 0,5 for the whole dodge and 0,26 for the iframes.
The first method was using animation notifies to turn iframes on at the 3rd frame and off at the 19th frame while printing a message in the engine log. The iframe on and off messages printed in the output log varied having 0,26 and 0,27 seconds between them.
The second method was using the event "Set Timer by Function Name" to have a function turn on iframes 0,05 seconds after dodge begins and another timer to have a function turn off the iframes after 0,26 seconds. Once again log reported the time between iframes on and off to vary between 0,26 and 0,27 seconds.
The third method was to mix an animation notify with a timer. So once again the 3rd frame of the dodge animation has an animation notify that turns iframes on and begins a timer of 0,26 seconds to call a function that turns the iframes off. The results again varied between 0,26 and 0,27 seconds.
So the results were the same for all three methods. With my testing, I can't say for sure which is the best, but I have a feeling that using timers give more accurate result in the case that the animation notifies have problems if the game is running at a low frame rate on a lower-end PC. For now, I've kept the third method so that the 3rd frame of the animation is always the one to call the iframes to be turned on.
As for the log messages varying by 0,01 seconds, the timestamps might get rounded up or there is a real variance. In either case, it's not something I noticed in actual gameplay but I'll be keeping my eye on it and for any better methods to implement iframes.
In the video clip below I'm testing the dodging and iframes. The rotating object attempts to damage the player when they overlap. Red text indicating that the player has received damage is printed in the top left and a yellow text is printed if the overlap happens when the player's iframes are active.


