blocking wall at the side of screen

Hi! I’m try to create a game for phone. I create a wall blueprint for blocking all actors at the edge of screen. According to phone’s different aspect ratio. I first set up a small image at the side of hud and set anhor for it called “right”.
Then I set codes so the wall location match to the image on Hud. But the result is not working. Please help!!!

This whole thing is not that easy. Are you doing this for android or ios?

First you need to calculate where corners of screen are: (deproject node)
Get Screen Location to World Space - UE4 AnswerHub

Then move blocking meshes there. That is for windows.

But mobiles are bit more complicated as they can change screen resolution during gameplay.

use this

Nah I don’t think Ue4 supports screen rotation on mobile by default

So I add a small size image call “right” on the widget blueprint and set anchor for it to get the screen edge location. but My wall blueprint does not following the location of it.

When starting the game. the wall is still in the middle of the screen

The Render Transform of a widget is not it’s screen position, it’s a relative transform from it’s original position. What you want to do is “Get Viewport Size” from your player controller. That’ll give you the pixel dimensions of your viewport. (0, 0) on the screen is the top left corner, so if you want the middle of the left side of the screen it’s (0, y/2), and the middle of the right side is (x, y/2), etc. Convert those coordinates to world space. According to this post, the World Location output is a point on your camera’s near plane—not a location that’s very useful by itself. You need to cast a line trace from that World Location, in World Direction, until you hit whatever “floor plane” you want your wall to be spawned on.