Line Trace won't rotate

Hi everyone, I have a problem right now with line traces, I’m trying to make a line trace that goes from the camera to the world, so the trace actually get shot from the camera position but I can’t find any place where to set the rotation for the trace to be shot, so is there anyway to tell the trace the rotation it needs to to use so it goes to my world?

The is the original line trace that I’m getting from the code:

This is what I desire to get, the line:

This is the code I’m using:

FVector startTraceLocation;
		FRotator startRotacionLocation;

		mainCamera->GetActorEyesViewPoint(startTraceLocation, startRotacionLocation);

		const FName TraceTag("MyTraceTag");

		GetWorld()->DebugDrawTraceTag = TraceTag;

		FCollisionQueryParams RV_TraceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);
		RV_TraceParams.bTraceComplex = true;
		RV_TraceParams.bTraceAsyncScene = true;
		RV_TraceParams.bReturnPhysicalMaterial = false;
		RV_TraceParams.TraceTag = TraceTag;

		//Re-initialize hit info
		FHitResult RV_Hit(ForceInit);

		//call GetWorld() from within an actor extending class
		GetWorld()->LineTraceSingle(RV_Hit,        //result
									startTraceLocation,    //start
									FVector(startTraceLocation.X, startTraceLocation.Y, 0) + (startRotacionLocation.Vector() * 256), //end
									ECC_WorldDynamic, //collision channel
									RV_TraceParams);

Hello ,

When trying to get the end location of the trace with the correct rotation, you can do so by using the forward vector of the camera. You can calculate it like so:

CameraComponent->GetComponentLocation() + CameraComponent->GetForwardVector() * 2000

Where 2000 is the distance you want the line trace to go. This should point it in the correct direction for you.

Hope this helps!

Hi mark, It kind of worked great but now it only shoots in that one direction, ho can I offset that trace to be modified bi the touch screen position or the click position, should I multiply that CameraComponent->GetForwardVector() with my touchPosition.X and touchPosition.Y so I can send the trace exactly where the screen was clicked?

I usually use this to handle this kind of problem: Get Hit Result Under Cursor by Channel | Unreal Engine Documentation

Thank you Juse4pro, I used GetHitResultUnderCursor() to get the desired position.