[C++]I need help with a building system

So iam trying to make something spawn on my mouse location in a 3d world space. but it seems that the coordinates are totaly wrong ! Iam not getting an error or something.


 APlayerController* cont = GetWorld()->GetFirstPlayerController();
     if (cont)
     {
         FVector start;
         FRotator camrot;
         GetActorEyesViewPoint(start, camrot);
         FVector2D mousePos;
         cont->GetMousePosition(mousePos.X,mousePos.Y);//here i get the 2d mouse position
         FVector mouseinWorldSpace = FVector(mousePos.X,mousePos.Y,0);
         FVector dir;
         cont->DeprojectMousePositionToWorld(mouseinWorldSpace,dir);//and here the 3d mouse position
         FVector end = mouseinWorldSpace;
         end.Z -= 1000;
         FHitResult hit;
         FCollisionQueryParams params;
         params.AddIgnoredActor(this);
         if (Raycast(start, end, hit, params))//then i shoot a simple linetrace to the 3d mouse position
         {
             UWorld* world = GetWorld();
             if (world)
             {
                 DrawDebugLine(world, start, hit.Location, FColor(255, 0, 0), true, 100, 0, 12);//and then i want to spawn this line where my mouse pos is but it dosent work
             }
         }
     }

I hope someone can help me,
Gunschlinger

Fixed it !

APlayerController* cont = GetWorld()->GetFirstPlayerController();
if (cont)
{
FVector start;
FRotator camrot;
cont->GetActorEyesViewPoint(start, camrot);
FHitResult hit;
FCollisionQueryParams params;
params.AddIgnoredActor(this);
if (cont->GetHitResultUnderCursor(ECC_PhysicsBody, false, hit))
{
UWorld* world = GetWorld();
if (world)
{
world->SpawnActor<class AActor>(test, FVector(hit.Location.X,hit.Location.Y,150), FRotator::ZeroRotator);
}
}
}