protected override void ReceiveTick_Implementation(float DeltaSeconds) { base.ReceiveTick_Implementation(DeltaSeconds); // Determine which Puzzle Block the player is looking at and highlight it. if (UHeadMountedDisplayFunctionLibrary.IsHeadMountedDisplayEnabled()) { UCameraComponent camera = VrCamera; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); FVector start = camera.GetWorldLocation(); FVector end = start + (camera.GetWorldRotation().GetForwardVector() * 8000); FHitResult hitResult; bool hit = USystemLibrary.LineTraceSingle(this, start, end, UEngineTypes.ConvertToTraceType(ECollisionChannel.Camera), false, null, EDrawDebugTrace.None, out hitResult, true, FLinearColor.Red, FLinearColor.Green, 0); APuzzleBlock block = hit ? hitResult.Actor.Value as APuzzleBlock : null; if (block != null) { CurrenBlockFocus = block; block.DoHighlight(true); } else if (CurrenBlockFocus != null) { CurrenBlockFocus.DoHighlight(false); CurrenBlockFocus = null; } } }
protected override void BeginPlay() { base.BeginPlay(); // Choose Camera based on whether HMD is enabled if (UHeadMountedDisplayFunctionLibrary.IsHeadMountedDisplayEnabled()) { VrCamera.Activate(); } else { FpCamera.Activate(); } }