How to selectively limit player movement within viewport?

Hi,

I’m working on a top down shooter where the camera occasionally will move around the player to show off the environment, like in Ikaruga for example, except you can still move the player. I’d like to limit player movement to within screen boundaries and most importantly be able to selectively disable those boundaries for when the camera starts moving and zooming around. I’d like to stay away from invisible walls because they seem harder to control.

Here’s the input event:

I normalized the axis vectors so that diagonal speed is the same as regular speed. I borrowed the above part from [this helpful answer][2] in order to check player position. I get 2 vectors for horizontal and vertical movement.

I then send the resulting movement vectors into the update event:

Player moves around with no issues, but flies outside the screen. Any ideas?