How can i shoot at the center of my crosshair? C++

Hi, sorry I am too tired right now, I just took a quick look and found something:

if( MyPC->DeprojectScreenPositionToWorld((Viewport.X), (Viewport.Y), WorldPosition, WorldDirection))

if you want to get the screen center you have to devide the size by 2 or even better to multiply it by 0.5 :slight_smile:

if( MyPC->DeprojectScreenPositionToWorld((Viewport.X * 0.5f), (Viewport.Y * 0.5f), WorldPosition, WorldDirection))

P.S. for me the deproject works fine I am on 4.16.3 though…

If you can’t get the screen size
maybe you can try this function

const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());