Guest User

Untitled

a guest
Jul 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. // Copyright Angelos Papavlasopoulos 2018
  2.  
  3. #include "Grabber.h"
  4. #include "Engine/World.h"
  5. #include "DrawDebugHelpers.h"
  6.  
  7. #define OUT
  8.  
  9. // Sets default values for this component's properties
  10. UGrabber::UGrabber()
  11. {
  12. // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
  13. // off to improve performance if you don't need them.
  14. PrimaryComponentTick.bCanEverTick = true;
  15.  
  16. // ...
  17. }
  18.  
  19.  
  20. // Called when the game starts
  21. void UGrabber::BeginPlay()
  22. {
  23. Super::BeginPlay();
  24. UE_LOG(LogTemp, Warning, TEXT("Grabber reporting for duty!"));
  25.  
  26. // ...
  27.  
  28. }
  29.  
  30.  
  31. // Called every frame
  32. void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
  33. {
  34. Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
  35.  
  36. // get player view point this tick
  37. FVector PlayerViewPointLocation;
  38. FRotator PlayerViewPointRotation;
  39. GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT PlayerViewPointLocation, OUT PlayerViewPointRotation);
  40.  
  41.  
  42. //log out to test
  43. UE_LOG(LogTemp, Warning, TEXT("Location: %s Rotation: %s"), *PlayerViewPointLocation.ToString(), *PlayerViewPointRotation.ToString())
  44.  
  45.  
  46. FVector LineTraceEnd = PlayerViewPointLocation + (PlayerViewPointRotation.Vector() * Reach);
  47.  
  48.  
  49. // draw a red trace
  50.  
  51. DrawDebugLine(GetWorld(), PlayerViewPointLocation, LineTraceEnd, FColor(255, 0, 0), false, 0.f, 0.f, 10.f);
  52.  
  53. // ray cast out to reach distance
  54.  
  55. // see what we hit
  56. }
Add Comment
Please, Sign In to add comment