Limit player movement to edges of screen?

I’m working on an on-rails shooter style game similar to starfox, but I’m not sure about this aspect. I want the player, once they reach the edge of the screen, to be unable to move any further in that direction. I’m primarily an artist, so I might be missing something obvious, but the only idea I had was to make boxes for collision along the outside of the camera and find a way for it to selectively block only the player. Is this correct (or possible), or is there a better way?

I’m a programmer and my first thoughts of how to do this would be to get the location of the object in screen space (if UE4 doesn’t have a function for this, you can use do some matrix manipulation) and test if that object in screen space is in the negative X or Y, meaning its on the left or above the screen edge, or greater than the screen width or height, meaning its on the right or below the screen edge.

This is just my initial thoughts, depending on how your game systems are designed this might or might not work for you.

There is a “Convert World Location to Screen Location” blueprint node. I think it could lead somewhere. I can also get the screen size, so it’s a matter of comparing them, and if it’s greater than that or <= 0 I do… something. If I could somehow toggle the ability to move in that direction this would wrap up nicely. Thanks for a good start though.

EDIT: I believe I can add a boolean to the input like CanMoveNegX, and when the above conditions are met, it can be set to false. The other inputs work, and that one is disabled until the moment they move in the opposite direction.

Momentum might carry the ship further in that direction than you want though, you might also want to try applying a little gentle velocity in the proper direction to get the player back toward the center of the screen when they are off it. Good Luck