Advertisement
Panakotta00

PlayerControll.cpp

Jul 26th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include "Factorio3D.h"
  2. #include "PlayerControll.h"
  3.  
  4. AActor* PC_Actor;
  5. UWorld* PC_World;
  6. APlayerCameraManager* cm;
  7.  
  8. APlayerControll::APlayerControll() {
  9. PrimaryActorTick.bCanEverTick = true;
  10.  
  11. PC_Actor = Cast<AActor>(this);
  12. }
  13.  
  14. void APlayerControll::BeginPlay() {
  15. Super::BeginPlay();
  16.  
  17. PC_World = PC_Actor->GetWorld();
  18. cm = PlayerCameraManager;
  19. }
  20.  
  21. void APlayerControll::Tick(float DeltaTime) {
  22. Super::Tick(DeltaTime);
  23.  
  24. FVector* c_loc = new FVector();
  25. FVector* c_dir = new FVector();
  26. FHitResult* hit = new FHitResult();
  27. FCollisionQueryParams* cp = new FCollisionQueryParams();
  28. cp->AddIgnoredActor(PC_Actor);
  29. cp->AddIgnoredActor(PlayerCameraManager);
  30. if (DeprojectMousePositionToWorld(*(c_loc), *(c_dir))) {
  31. if (PC_World->LineTraceSingleByChannel(*hit, cm->GetCameraLocation(), *c_loc + *c_dir * 1000, ECC_Pawn, *cp) && hit->GetActor() != nullptr) {
  32. hit->GetActor()->SetActorLocation(hit->GetActor()->GetActorLocation() + *(new FVector(0, 1, 0)));
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement