Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright Angelos Papavlasopoulos 2018
- #include "Grabber.h"
- #include "Engine/World.h"
- #include "DrawDebugHelpers.h"
- #define OUT
- // 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.
- 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);
- //log out to test
- UE_LOG(LogTemp, Warning, TEXT("Location: %s Rotation: %s"), *PlayerViewPointLocation.ToString(), *PlayerViewPointRotation.ToString())
- FVector LineTraceEnd = PlayerViewPointLocation + (PlayerViewPointRotation.Vector() * Reach);
- // draw a red trace
- DrawDebugLine(GetWorld(), PlayerViewPointLocation, LineTraceEnd, FColor(255, 0, 0), false, 0.f, 0.f, 10.f);
- // ray cast out to reach distance
- // see what we hit
- }
Add Comment
Please, Sign In to add comment