I am raycasting from c++ to a blutprint which is an actor.
The code looks like this:
FHitResult f(ForceInit);
FVector pos;
FVector dir;
FCollisionQueryParams CombatCollisionQuery(FName(TEXT("CombatTrace")), true, NULL);
CombatCollisionQuery.bTraceComplex = true;
CombatCollisionQuery.bTraceAsyncScene = false;
CombatCollisionQuery.bReturnPhysicalMaterial = false;
pc->DeprojectMousePositionToWorld(pos, dir);
FVector mouseEnd = dir * 100000;
this->Mesh->LineTraceComponent(f, pos, mouseEnd, CombatCollisionQuery);
FString s = FString(f.Location.ToString());
auto a = pc->GetWorld();
DrawDebugLine(a, pos, mouseEnd , FColor(1.0f,0.f,0.f,1.f),false,10.f);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, s);
Which looks like this
note that I have moved the camera a bit so that you can see the debug rays
The rays seem to be in the correct position. The object that you see is a Blueprint actor with a static mesh and the collision is set to block all, and a static light that I can trigger with the left mouse button via the OnClicked event, which is probably also doing a raycast.
The hit location is always 0 0 0, and it also doesn’t find an actor.
What have I done wrong?