Simple ray trace

I desperately need help with this. It’s driving me insane.

All I want to do is detect when I’m looking at any actor with a certain channel. I’m calling it “Interactive”. I don’t know whether to make it an object or trace channel because I’ve tried both and neither works.

The actor must not collide with anything. In the static mesh, I set collision presets to NoCollision.

In the actor’s constructor, I have:

BaseMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_GameTraceChannel1, ECollisionResponse::ECR_Block);

In the player’s tick, I have:

FHitResult out_hit;
    FVector forward = FirstPersonCameraComponent->GetForwardVector();
    FVector start = FirstPersonCameraComponent->GetComponentLocation(); // + (forward * 100.0F)
    FVector end = start + (forward * 300.0F);
    FCollisionQueryParams collision_params;

    //DrawDebugLine(GetWorld(), start, end, FColor::Green, false, 1, 0, 1);

    FCollisionObjectQueryParams params;

    bool hit = GetWorld()->LineTraceSingleByChannel(out_hit, start, end, ECC_GameTraceChannel1, collision_params);

    if (!hit || !out_hit.bBlockingHit)
        HelperMethods::Debug("s", "Looking at nothing");

    AActor* a = out_hit.GetActor();
    HelperMethods::Debug("s", TCHAR_TO_ANSI(*a->GetName()));

    HelperMethods::Debug("ss", "Looking at item of type: ", TCHAR_TO_ANSI(*a->GetClass()->GetName()));

It just keeps saying that I’m looking at the player controller. Please help me with this.

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

for ignore a actor, GetOwner() for the parent
[TABLE=“cellspacing: 0”]



FName InTraceTag,
bool bInTraceComplex,
const AActor * InIgnoreActor

Add the character you are controlling and any separate held equipment to the “IgnoredActor” list in your query params. Example:

 // ignore currently controller character and held equipment in ray casts
 FCollisionQueryParams rayTraceParameters(FName("Trace"), true);
 rayTraceParameters.bTraceComplex = false;

Your CollisionEnabled setting of No Collision is incorrect. It must be Query Only or Query and Physics for raytraces to work.