DestinationMark rotates itself while I move my motion controller
my code:
bool AVR_Character::FindTeleportDestination(TArray& OutPath, FVector& OutLocation)
{
FVector Look = RightMotionController->GetForwardVector();
FVector Location = RightMotionController->GetComponentLocation() + Look * 15.0f;
FPredictProjectilePathParams Params(TeleportProjectileRadius, Location, Look * TeleportProjectileSpeed, TeleportSimulationTime, ECollisionChannel::ECC_MAX, this);
Params.DrawDebugType = EDrawDebugTrace::ForOneFrame;
Params.bTraceComplex = true;
FPredictProjectilePathResult Result;
bool bSucess = UGameplayStatics::PredictProjectilePath(this, Params, Result);
if (!bSucess) return false;
for (FPredictProjectilePathPointData PointData : Result.PathData)
{
OutPath.Add(PointData.Location);
};
FNavLocation Navigation;
bool bNavigative = UNavigationSystemV1::GetCurrent(GetWorld())->ProjectPointToNavigation(Result.HitResult.Location, Navigation, TeleportationExtent);
if (!bNavigative)return false;
OutLocation = Navigation.Location;
return true;
}
void AVR_Character::LocationTeleportDistance()
{
TArray<FVector> Path;
FVector Location;
bool bHasDestination = FindTeleportDestination(Path, Location);
if (bHasDestination)
{
DestinationMark->SetVisibility(true);
DestinationMark->SetWorldLocation(Location);
}
else
{
DestinationMark->SetVisibility(false);
}
}