On UE5:
When I play in the non-vr mode (Selected View Port). I can move forward and the tunnel is in the center, if I move anywhere else it shoots to the top left of the screen. Playing in VR its just completely black… On Standard Rift
Edit: When I simulate (Not VR Mode) and go diagonally the tunnel moves to perfectly horizontal. So either (0,.5) or (1, 0.5). VR Mode is still black.
Edit 2: So I found the reason this is broken, but I don’t have a good fix for it. GetViewportSize, Y returns 1280, but X is Zero…it’s always zero. Manually putting something in here makes things a bit more stable but I shouldn’t have to hardcode viewport resolutions. Any idea’s?
My Code is as follows:
void AVRCharacter::UpdateBlinker()
{
if (!RadiusVsVelocity) return;
float Velocity = GetVelocity().Size();
float Radius = RadiusVsVelocity->GetFloatValue(Velocity);
BlinkerMaterialInstance->SetScalarParameterValue(TEXT("Focus Radius"), Radius);
FVector2d Center = GetBlinkerCenter();
BlinkerMaterialInstance->SetVectorParameterValue(TEXT("Center"), FLinearColor(Center.X, Center.Y, 0));
}
FVector2d AVRCharacter::GetBlinkerCenter()
{
FVector MovementDirection = GetVelocity().GetSafeNormal();
APlayerController* PC = Cast<APlayerController>(GetController());
if (MovementDirection.IsNearlyZero() || !PC) return FVector2d(0.5, 0.5);
FVector2d ScreenStationaryLocation;
FVector WorldStationaryLocation = Camera->GetComponentLocation() + MovementDirection * 1000;
PC->ProjectWorldLocationToScreen(WorldStationaryLocation, ScreenStationaryLocation);
int32 SizeX, SizeY;
PC->GetViewportSize(SizeX, SizeY);
ScreenStationaryLocation.X /= SizeX;
ScreenStationaryLocation.Y /= SizeY;
return ScreenStationaryLocation;
}
Material is attached.