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.
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.