Skip to content

Instantly share code, notes, and snippets.

@teukstrid
Created May 5, 2018 17:59
Show Gist options
  • Save teukstrid/9bbf640b021529c6545e58f09094e545 to your computer and use it in GitHub Desktop.
Save teukstrid/9bbf640b021529c6545e58f09094e545 to your computer and use it in GitHub Desktop.
PlayerViewPoint log problem
#include "Grabber.h"
#include "BuildingEscape.h"
#include "Components/InputComponent.h"
#include "GameFramework/Actor.h"
#include "CoreMinimal.h"
#include "Engine.h"
// Sets default values for this component's properties
UGrabber::UGrabber()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
bWantsBeginPlay = true;
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UGrabber::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning, TEXT("Grabber reporting for duty!"));
}
// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// Get player view point this tick
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT PlayerViewPointLocation, OUT PlayerViewPointRotation);
// TODO Log out to test
UE_LOG(LogTemp, Warning, TEXT("Location: %s, Rotation: %s") *PlayerViewPointLocation.ToString(), *PlayerViewPointRotation.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment