Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
        protected override void BeginPlay()
        {
            base.BeginPlay();

            // Spawn blocks
            for (int i = 0; i < Size * Size; i++)
            {
                float x = (i % Size) * BlockSpacing;
                float y = (i / Size) * BlockSpacing;

                FVector      location = GetActorLocation() + new FVector(x, y, 0);
                APuzzleBlock block    = World.SpawnActor <APuzzleBlock>(location, default(FRotator));
                block.OwningGrid = this;
            }
        }