I’m trying to get the world location of the edge of the screen so that I can have attacks shoot from the edge of the screen. Anyone have any idea how to do this? I’ve tried the following.
But seams to always be slightly below centers of screen, which doesn’t seam correct. All the existing posts about this were for mouse location to world location, which isn’t what I need. I specifically need viewport.
If C++ is required and can’t do this from BP that’s also fine as I’ve a utility plugin for attack behavior that I can just add that to.
You can try a line trace from the camera, coaxial with the camera cone (rotated at the FOV angles)
Then you will hit the edge of the screen (in theory)
Have you tried using get viewport size, break the struct and divide by two. This would be distance to edge of the screen from middle of the screen. You could then add a small offset so you are few pixels away from screen edge.
I am away from PC right now, so I can’t test it right now.
Issue is probably with Viewport Position != Screen Position I’m guessing. There’s no BP node for Viewport to Screen, but there is a Screen to Viewport.
Believe I may have got it. Took a page from converting mouse position to world position with plane line intersection and applied to translation of screen to world.
Awesome, confirmed this works for all screen edge locations that I wanted. So if anyone needs this you can just use the above to accomplish it. Adjust that Screen X/Y you feed into DeprojectScreenToWorld and that’s all there is to it.