Does anyone know what the ETraceTypeQuery is? Its a type that is passed into functions such as GetHitResultAtScreenPosition and GetHitResultUnderCursorByChannel, but I’m not sure what it is.
I’m using the previously mentioned functions to make a character look at the mouse in a top-down shooter. The problem is when the mouse moves over an obstacle it interferes with the direction the character faces. I was hoping the ETraceTypeQuery could solve this issue, just not sure how to use it.
Here is the code that I have:
void ALaserTagPlayerController::RotateToMouseCursor()
{
FHitResult Hit;
//The two lines below have the same effect
//GetHitResultUnderCursorByChannel(TraceTypeQuery1, false, Hit);
GetHitResultAtScreenPosition(Cast<ULocalPlayer>(Player)->ViewportClient->GetMousePosition(), TraceTypeQuery1, true, Hit);
const FVector PlayerPos = GetWorld()->GetFirstPlayerController()->GetCharacter()->GetActorLocation();
FRotator PlayerRot = FRotationMatrix::MakeFromX(Hit.Location - PlayerPos).Rotator();
PlayerRot.Pitch = 0.0f;
this->GetCharacter()->SetActorRotation(PlayerRot);
}
Thanks