# ProjectWorldLocationToScreen() returning garbage?

**URL:** <https://forums.unrealengine.com/t/projectworldlocationtoscreen-returning-garbage/460642>\
**Category:** C++\
**Tags:** screen-space, unreal-engine, CPP, question\
**Created:** [January 16, 2020, 6:00pm UTC](https://forums.unrealengine.com/t/projectworldlocationtoscreen-returning-garbage/460642 "2020-01-16T18:00:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WarpSpider833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WarpSpider833](https://forums.unrealengine.com/u/WarpSpider833)\
**Post date:** [January 16, 2020, 6:00pm UTC](https://forums.unrealengine.com/t/projectworldlocationtoscreen-returning-garbage/460642/1 "2020-01-16T18:00:41Z")

</div>

When I use the following code in a custom AActor class in the level:

```
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();

FVector2D ScreenLocation;
PlayerController->ProjectWorldLocationToScreen(WorldLocation, ScreenLocation);

int32 ScreenWidth = 0;
int32 ScreenHeight = 0;
PlayerController->GetViewportSize(ScreenWidth, ScreenHeight); // This works

int32 ScreenX = (int32)ScreenLocation.X;
int32 ScreenY = (int32)ScreenLocation.Y; // This does not

```

The ScreenX and ScreenY values return nonsense values when printed - I assume from uninitialized memory access. The WorldLocation FVector that I’m feeding this is fine (I use it elsewhere). I don’t think the issue is the playercontroller, as it gives me the correct viewport size, but I could be wrong.

Any thoughts? Or a better way to do this?

---

<div class="post-metadata">

**Author:** ![WarpSpider833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WarpSpider833](https://forums.unrealengine.com/u/WarpSpider833)\
**Post date:** [January 16, 2020, 6:29pm UTC](https://forums.unrealengine.com/t/projectworldlocationtoscreen-returning-garbage/460642/2 "2020-01-16T18:29:58Z")

</div>

This was actually an issue with my World Location coordinates, this should work fine for anyone else!
