code
// Fill out your copyright notice in the Description page of Project Settings.
#include "GameFramework/PlayerController.h"
#include "Engine/World.h"
#include "DrawDebugHelpers.h"
#include "Graber.h"
#define OUT
// Sets default values for this component's properties
UGraber::UGraber()
{
// 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 UGraber::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning,TEXT("Graber reporting for duty"));
}
// Called every frame
void UGraber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint( OUT PlayerViewPointLocation, OUT PlayerViewPointRotation);
FVector LineTraceEnd= PlayerViewPointLocation + PlayerViewPointRotation.Vector()*Reach;
DrawDebugLine(
GetWorld(),
PlayerViewPointLocation,
LineTraceEnd,
FColor(0,255,0),
false,
0.f,
0,
5.f
);
FHitResult Hit;
FCollisionObjectQueryParams TraceParams(FName(TEXT("")), false, GetOwner());
GetWorld()->LineTraceSingleByObjectType(
OUT Hit,
PlayerViewPointLocation,
LineTraceEnd,
FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
TraceParams
);
AActor* ActorHit = Hit.GetActor();
if (ActorHit)
{
UE_LOG(LogTemp,Error, TEXT("Line trace has hit: %s "), *(ActorHit->GetName()))
}
}
ERROR 1
'FCollisionObjectQueryParams::FCollisionObjectQueryParams': no overloaded function takes 3 arguments
ERROR 2
bool UWorld::LineTraceSingleByObjectType(FHitResult &,const FVector &,const FVector &,const FCollisionObjectQueryParams &,const FCollisionQueryParams &) const': cannot convert argument 5 from 'FCollisionObjectQueryParams' to 'const FCollisionQueryParams &'