Hi there!
Are you passing in a value of world origin?
That is an out parameter, you are supposed to pass in a FVector to be filled with the world origin data by deproject, which you can then use for doing traces to obtain the z value
The only in parameters for deproject are the 2D coordinates, all others are out parameters.
When you are deprojecting it will be near the camera, because you are going from the 2D plane of the canvas to 3d space, so it starts close to current camera view.
You cannot expect deproject to account for a Z value when it is being given 2D coordinates, what z value would you like it to decide upon? You must determine the Z value yourself using a trace.
After you deproject are you doing a trace from the deprojected point down into the world? See my code below
if you want to trace exact hit location you can use
//Did Not Hit Anything?
if(!TraceHit.bBlockingHit) return;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Get Hit Loc
FVector HitLoc = TraceHit.ImpactPoint();
If you use all of my code below you will rotate the SMA’s in your level by clicking on them with this function 
I use deproject in my game’s custom HUD class to click on objects in the world all the time!
I posted my entire code for making an ingame mouse cursor a while ago
here’s the whole tutorial, including a video showing it working
http://forums.epicgames.com/threads/972861-Tutorial-Compile-C-for-UE4-Code-Samples-For-You-gt-gt-New-Get-Set-AnimBluePrint-Vars?p=31656285&viewfull=1#post31656285
here’s the function most related to your question
//if player controller mouse button clicked
//then do trace
void AYourHUD::CursorGetClickedActor()
{
APlayerController* ThePC = GetOwningPlayerController();
//could not get PC ?
if(!ThePC) return;
//Was LeftMouseButton Just Clicked?
if(!ThePC->WasInputKeyJustPressed(EKeys::LeftMouseButton)) return;
//~~~~~~~~~~
//no canvas for some reason?
if(!Canvas) return;
//~~~~~~~~~~~~~~~~~~
/**
* Transforms 2D screen coordinates into a 3D world-space origin and direction.
* @param ScreenPos - screen coordinates in pixels
* @param WorldOrigin (out) - world-space origin vector
* @param WorldDirection (out) - world-space direction vector
*/
//void Deproject(FVector2D ScreenPos, /*out*/ FVector& WorldOrigin, /*out*/ FVector& WorldDirection);
FVector Origin;
FVector WorldDir;
Canvas->Deproject(MouseLocation,Origin,WorldDir);
//Trace
FCollisionQueryParams TraceParams(FName(TEXT("HUDClick")), this);
//TraceParams.bTraceComplex = true;
//TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = false;
//Re-initialize hit info
FHitResult TraceHit = FHitResult(ForceInit);
GetWorld()->LineTraceSingle(
TraceHit, //result
Origin, //start
Origin + 70000 * WorldDir , //end
ECC_PawnMovement, //collision channel
TraceParams
);
//Did Not Hit Anything?
if(!TraceHit.bBlockingHit) return;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Get Hit Actor
AActor* HitActor = TraceHit.GetActor();
//Could not get actor?
if (!HitActor) return;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Check Hit a Static Mesh Actor
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(HitActor->IsA(AStaticMeshActor::StaticClass()))
{
//attempt cast to SMA
AStaticMeshActor* HitWall = Cast(HitActor);
//could not cast to SMA some reason?
if (!HitWall) return;
//Static mesh actor has component?
if(!HitWall->StaticMeshComponent) return;
//Just a fun little test, repeatedly rotates clicked static mesh
FRotator TheRot = HitWall->GetActorRotation();
TheRot.Yaw += 3; //rotators are in degrees now, yaaay!
TheRot.Pitch += 3;
HitWall->SetActorRotation(TheRot);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}