Could I get some help in understanding (FName(TEXT("HUDClick")), this);?

Hi…

I am testing the function LineTraceSingle

Mostly I cannot understand this part of the code.

	FCollisionQueryParams TraceParams(FName(TEXT("HUDClick")), this);
	//TraceParams.bTraceComplex = true;
	//TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;

What does (FName(TEXT(“HUDClick”)), this); do here?

And I got error when I used this part.

1>D:\ue4\New folder\MyProject\Source\MyProject\MyProjectHUD.cpp(41): error C2220: warning treated as error - no ‘object’ file generated
1>D:\ue4\New folder\MyProject\Source\MyProject\MyProjectHUD.cpp(41): warning C4800: 'AMyProjectHUD *const ’ : forcing value to bool ‘true’ or ‘false’ (performance warning)

But when I removed it, I didn’t get any error when I used this…

FCollisionQueryParams TraceParams;//(FName(TEXT("HUDClick")), this);
	//TraceParams.bTraceComplex = true;
	//TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;

	//Re-initialize hit info
	FHitResult TraceHit = FHitResult(ForceInit);

So what exactly is that part and what does it do?

It’s calling the constructor of FCollisionQueryParams with an FName and a pointer, however I think you’re missing a parameter (hence the warning about converting an AActor* to a bool).

This is the signature of the constructor I think you’re trying to call:

FCollisionQueryParams(FName InTraceTag, bool bInTraceComplex=false, const AActor* InIgnoreActor=NULL)

You probably want:

FCollisionQueryParams TraceParams(FName(TEXT("HUDClick")), false, this);

Ok… The documentation is showing a 404 error…

So how any other way to know how the constructor works?

Even if you’re not using the GitHub source, you will at least have access to the header files to be able to use UE4, so if you’re using Visual Studio, pressing F12 (Alt+G if you also have Visual Assist) should take you to the declaration of a type/function.