Covert Raycasting Blueprint to C++

Hi there, I’m trying to convert some of my game’s blueprint into C++ code and I’m having trouble with raycasting. The blueprint version works, but my C++ code is not.

Right now, the blueprint looks like this


My code looks like this:


Right now I don’t want my raycast in my C++ code to ignore certain actors because I want to first make sure the raycast actually works first before adding constraints.

But besides that, what am I doing wrong?

Advance thanks to anyone that can help me with my problem.

DrawDebugLine
(
GetWorld(),
StartTrace, // Start Trace
HitResult.Location, // Hit Result Location
FColor(255, 0, 0), // Red
false, // Persistent Lines
2.0, // Time
0, // Depth Priority
2.0 // Thickness
);

It might help you to debug where you are currently line tracing. :slight_smile:

So we’ll start from there. Also, I haven’t tested your code yet but it seems like it should be working. You could try adding a debug message in your Line Trace to grab the name of whatever it hit to see what it was.

Also, try using this solution instead.

			if (GetWorld()->LineTraceSingle(HitResult, StartTrace, EndTrace, ECC_Visibility, TraceParams))
			{
                             //Stuff here.
			}

Thank you, that last solution worked.