I have figured out the problem. I was cheeking only X or only Z, but if the character was going both positive X and Z the flip books were overlapping because I didn’t have a statement to check the condition. Here is the updated code:
void Aside2DcharCharacter::UpdateAnimation()
{
const float PlayerSpeed = GetVelocity().X;
const float TravelDirection = GetVelocity().Z;
// Running animation if the character is moving only X axis but not Z axis
if (PlayerSpeed > 0.0f && TravelDirection == 0.0f ||
PlayerSpeed < 0.0f && TravelDirection == 0.0f)
GetSprite()->SetFlipbook(RunningAnimation);
// Jumping Animation if the character is jumping straight up or or together with any X axis
else if (TravelDirection > 0.0f ||
TravelDirection > 0.0f && PlayerSpeed > 0.0f)
GetSprite()->SetFlipbook(JumpingAnimation);
// Falling animation if the character is falling straight down or together with any X axis
else if (TravelDirection < 0.0f ||
TravelDirection < 0.0f && PlayerSpeed < 0.0f)
GetSprite()->SetFlipbook(FallingAnimation);
// Idle animation if the character neither is falling or jumping
else
GetSprite()->SetFlipbook(IdleAnimation);
}