Movement blendspace, rotation towards mouse makes animations "laggy"

Hello fellow devs.

I recently moved from Unity to UE, so bear with me.

I have a 2D Blendspace with 8-way movement directions, set by speed and direction.

The issue im facing is that i am developing a top down shooter, where the player always look at the mouseposition. The problem occurs when i move the mouse, and the player rotates towards the new position, changing my “direction” varible for a short second making the blendspace play for example strafe forward directional instead of simply playing the forward animation.

GIF.

This is how i set the direction and speed for the blendspace.

Setting the controller movement

const FVector2D MovementVector = Value.Get<FVector2D>();


const FVector Forward = GetActorForwardVector();
AddMovementInput(Forward, MovementVector.Y);
const FVector Right = GetActorRightVector();
AddMovementInput(Right, MovementVector.X);

and lastly to rotate towards mouse:

APlayerController* PlayerController = Cast<APlayerController>(GetController());
	if (PlayerController)
	{
		FHitResult Hit;
		bool bHitSuccessful = false;
		bHitSuccessful = PlayerController->GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, Hit);

		// If we hit a surface, cache the location
		if (bHitSuccessful)
		{
			CachedDestination = Hit.Location;
			FVector WorldDirection = (CachedDestination - this->GetActorLocation()).GetSafeNormal();
			FRotator asdf = WorldDirection.Rotation();
			FRotator newOne = FRotator(0.f, asdf.Yaw, asdf.Roll);
			SetActorRotation(newOne);
			
		}
	}

I hope i expained my issue so that you can understand. I dont want the blendspace “direction” varible to be affected by my mouse movements.

Thank you for reading and spending time with me.

Okey so, instead of getting the direction from blueprint i created this horrible function. Dont laugh, it gets the job done. If anyone know any math formula that does what i am doing, please let me know.

YMovementMagnitudeAnim = PlayerCharacter->YMovementMagnitude;
		XMovementMagnitudeAnim = PlayerCharacter->XMovementMagnitude;

		testvalueForwardBackward = 180.f * YMovementMagnitudeAnim;
		testvalue = 90.f * XMovementMagnitudeAnim;

		returnVALL = 0.f;

		if (testvalue == 90.f && testvalueForwardBackward == -180.f)
		{
			returnVALL = 135.f;
		}
		else if(testvalue == -90.f && testvalueForwardBackward == -180.f)
		{
			returnVALL = -135.f;
		}
		else if (testvalue == 90.f && testvalueForwardBackward == 180.f)
		{
			returnVALL = 45.f;
		}
		else if (testvalue == -90.f && testvalueForwardBackward == 180.f)
		{
			returnVALL = -45.f;
		}
		else if(testvalue == -90.f && testvalueForwardBackward == 0)
		{
			returnVALL = -90.f;
		}
		else if (testvalue == 90.f && testvalueForwardBackward == 0)
		{
			returnVALL = 90.f;
		}
		else if (testvalue == 0.f && testvalueForwardBackward == 180)
		{
			returnVALL = 0.f;
		}
		else if (testvalue == 0.f && testvalueForwardBackward == -180)
		{
			returnVALL = -180.f;
		}
		else
		{
			returnVALL = 0.f;
		}