DeprojectScreenPositionToWorld not working at beginning of game?

Hey everyone! So I was wondering if anyone could help me out and let me know why DeprojectScreenPositionToWorld isn’t working in BeginPlay AND on the first frame of the Tick function, it still doesn’t work

But on the second frame in the Tick function, it works perfectly fine and I get the right world location from screen co-ords.

Otherwise I just get two random values that are very close to one another.
Please can someone me out and maybe help me fix this, any help is much appreciated, thank you! :smiley:

What object are you calling this from? It’s possible that not all of the required objects have been created at that time.

Im calling from some random actor and i guess that must be it

Projecting from the screen to the world requires your camera to be set up, so that you know what the screen would be showing. It looks like that camera information isn’t available until the camera has ticked at least once.

I imagine another option would be to do the math manually – where do you think the camera would be, what direction would it point in, and what’s your field of view? Do the math to create a line, which you can then trace against the world using the regular line trace function.

1 Like

Okay, thank you! I’ll try this out now :smiley: