i … realy don’t want tu use navmesh for player so i made this to calculate the angle betxeen vrroot upvector and the hit result normal vector (if inclination is too steep you shouldn’t be able to teleport and you also shold not be able to teleport to a wall) (i also turn the cilinder 90° for it to align with hitresult normal vector (i have to figure somthing else for the destination maker material tho it dosn’t look quite right when tilted as it has been made for flat surface))
if (BCol)
{
DestMarker->SetWorldLocation(RetCol.Location);
//calcul angle between up vector and normal vector
FVector playerVec = VRRoot->GetUpVector();
FVector normalVec = RetCol.ImpactNormal;
double Ajusted_adjacent = FVector::DotProduct(normalVec, playerVec) / normalVec.Size();
float angle = acos(Ajusted_adjacent / playerVec.Size()) * 180 / PI;
//activate desactivate destination maker
FRotator ColNormRot = RetCol.ImpactNormal.Rotation();
if ( angle < 20)
{
DestMarker->SetVisibility(true);
}
else
{
DestMarker->SetVisibility(false);
}
FRotator CorrectionRot = FRotator(90, 0, 0);
DestMarker->SetWorldRotation(ColNormRot + CorrectionRot);
}
else
{
DestMarker->SetVisibility(false);
}
then in my input function for the button press to teleport, i check if destination marker is visible and also i save the destination of the position of the marker before moving to prevent it from moving when i make the timer thingy.
void AVRCHAR::a_left_but_press()
{
if (DestMarker->IsVisible())
{
FVector destination = DestMarker->GetComponentLocation();
SetActorLocation(destination);
}
}