Why wont my LineTrace Detect anything?

New comer from unity here. Raycasting/Line trace is probably one of the most important aspects of a game but for some reason my line trace doesnt seem to detect anything. I love the engine so far but this is kind of frustrating. Ive been stuck on this simple problem for a few days now. Basically the only purpose for my linetrace is to interact with an interface that says “hey theres something that can be touched here.”

I have a simple Interface class, in it are 3 UFUNCTION()'s : OnFocusStart, OnFocusEnd, and OnInteract. In the character class, there is a hidden variable called focusedActor that stores the current actor looked at fr convenience sake. (These names might be a little butchered but they are all implemented fine). Then I have an actor class that implements the interface.

the problem lies within the linetrace function in my character class though. When I run it, I get the first debug and nothing else. It definitely ticks every frame because I have the tick function enabled, debug helper, AND when I place the debug outside of the we hit a new actor logic it updates every frame. Warning: the source code Im about to show may trigger some, but its for testing purposes only. I go back and cleanup after proof of concept

I really dont get what im doing wrong. My first implementation is supposed to be a door teleport script. I have a large static mesh in place of a door model with a collider that blocks everything but nothing works.

Is it a weird collision thing Im doing wrong? The root component system is really confusing. Even if I do a regular static mesh though theoretically it should debug as “found new object” anyways because its takes in any actor in the scene but no collision is happening for some reason. Any help is greatly appriciated!

Set whatever object you want the line trace to hit to blockall in its collision. You can do this in c++ or if you have a blueprint class of the c class, you can do it in the blueprint editor.
Make sure whatever object you want to collide with has a collision mesh or collision component. If your mesh doesnt have collision or you dont have a collision component the line trace will not hit.
Put log statement directly after if (bHit) to ensure the line trace is working.

Hi there, thank you for the response. I’ve done all of these things and the line trace does work. The debug spams the console when i put it after the first if statement. it wont detect anything though. The static meshes in my scene have colliders that block everything too.

check if focused object is valid, if it is then get the actors name and print that to the log as well. I suspect its the other if statements after this have the issue.

Here’s the code I’m using to check for interactive objects. COLLISION_INTERACTIVE is a trace channel I’ve set up, you can use Visibility or whatever else instead.
So the differences - I’m using actor eye location, as actor position (which is its pivot point) is usually at the bottom of the actor, as well as ignoring myself in the trace.
You should also check that the targeted actors block the trace channel you are testing against.

FVector EyeLocation;
FRotator EyeRotation;
GetActorEyesViewPoint(EyeLocation, EyeRotation);

FVector TraceDirection = EyeRotation.Vector();
FVector TraceEnd = EyeLocation + (TraceDirection * TargetTraceDistance);

FCollisionQueryParams QueryParams;

FHitResult Hit;
GetWorld()->LineTraceSingleByChannel(Hit, EyeLocation, TraceEnd, COLLISION_INTERACTIVE, QueryParams);

TargetActor = Hit.GetActor();

I appreciate your dedication to helping but this is from a while ago. If I remember correctly the problem was because the line trace was hitting the inside of the character collision. I still might use this for another time though, never knew you could set up custom collision channels