Building escape

What is wrong with my grabber
here is the error:

here is my cpp file for my grabber:

// DONT COPY KIDS

#include "DrawDebugHelpers.h"

#include "Engine/World.h"

#include "GameFramework/PlayerController.h"

#include "Grabber.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 the players viewpoint

    FVector PlayerViewPointLocation;

    FRotator PlayerViewPointRotation;

    GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(

        OUT PlayerViewPointLocation, 

        OUT PlayerViewPointRotation

        );

    //Draw a line from player showing the reach

    FVector LineTraceEnd = PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach`  ;

    DrawDebugLine(

        GetWorld(),

        PlayerViewPointLocation,

        LineTraceEnd,

        FColor(0, 255, 0),

        false,

        0.f,

        0,

        5.f

    );  

    FHitResult Hit;

    //Ray-cast out to a certain distance (Reach)

    FCollisionQueryParams TraceParams(FName(TEXT(""), false, GetOwner()));

    GetWorld() -> LineTraceSingleByObjectType(

        OUT Hit,

        PlayerViewPointLocation,

        LineTraceEnd,

        FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),

        TraceParams

    );

    //See what we are hitting

    AActor* ActorHit = Hit.GetActor();

    if (ActorHit)

    {

        UE_LOG(LogTemp, Error, TEXT("Line trace has hit %s"), *(ActorHit->GetName()));

    }

    

    //Logging out to test

}

here is my header file:

// DONT COPY KIDS

#pragma once

#include "CoreMinimal.h"

#include "Components/ActorComponent.h"

#include "Grabber.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )

class BUILDINGESCAPE_API UGrabber : public UActorComponent

{

    GENERATED_BODY()

public: 

    // Sets default values for this component's properties

    UGrabber();

protected:

    // Called when the game starts

    virtual void BeginPlay() override;

public: 

    // Called every frame

    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

private:

    float Reach = 100.f;

};

figured out the code

To potentially help others; the issue was a missing ) for FName here

FCollisionQueryParams TraceParams(FName(TEXT(""), false, GetOwner()));
                                        missing^

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms