Make camera move if player is on the edge of the screen

I want to make the camera move with the player if the player is moving to the edge of the screen, moving with him to always keep the player on the screen.

In the setup that I have, I have implemented a target lock system that sets the position of the root of the spring arm between the targeted AI and the player, so as we an see both the player and the AI. The issue is when you move the camera and the player character, you can have the camera look at the targeted AI while the player character is off screen.

I want it so that the camera always keeps the player on the screen, even if you move the camera and the player separately. A good example of this mechanic can be seen in Legend of Zelda: Breath of the Wild. The camera would either zoom out or move with Link as he approaches the edge of the screen (while in target lock mode) but the camera can still be moved by the player.

I hope that I’ve explained what I meant well, if not then I can edit the post and maybe provide diagrams to illustrate my issue.

1 Like

Did you ever figure this out? I’m hoping to work on this soon too :slight_smile:

This seems fitting, unsure if youtube links are good practice but it definetly is what youre looking for. https://www.youtube.com/watch?v=sesU3SPpn7o

Hi, I had a student who was hoping to figure this out, and I THINK this video can lead to something that would work:

I adapted the concept to a third-person template, and made a VERY BORING video showing what I did. Note, this is not a fun tutorial, it’s just me working my way through adapting the concept from the video above to make it work for my needs:

Hope this helps someone, I really haven’t seen anyone post anything that can do what we’re wanting.