Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Factorio3D.h"
- #include "PlayerControll.h"
- AActor* PC_Actor;
- UWorld* PC_World;
- APlayerCameraManager* cm;
- APlayerControll::APlayerControll() {
- PrimaryActorTick.bCanEverTick = true;
- PC_Actor = Cast<AActor>(this);
- }
- void APlayerControll::BeginPlay() {
- Super::BeginPlay();
- PC_World = PC_Actor->GetWorld();
- cm = PlayerCameraManager;
- }
- void APlayerControll::Tick(float DeltaTime) {
- Super::Tick(DeltaTime);
- FVector* c_loc = new FVector();
- FVector* c_dir = new FVector();
- FHitResult* hit = new FHitResult();
- FCollisionQueryParams* cp = new FCollisionQueryParams();
- cp->AddIgnoredActor(PC_Actor);
- cp->AddIgnoredActor(PlayerCameraManager);
- if (DeprojectMousePositionToWorld(*(c_loc), *(c_dir))) {
- if (PC_World->LineTraceSingleByChannel(*hit, cm->GetCameraLocation(), *c_loc + *c_dir * 1000, ECC_Pawn, *cp) && hit->GetActor() != nullptr) {
- hit->GetActor()->SetActorLocation(hit->GetActor()->GetActorLocation() + *(new FVector(0, 1, 0)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement