Top-Down Camera Help

Hello, everyone. I just starting my game project and I’m currently working on UPBGE. So, I want to make top-down RPG-style game, but I prefer it with 2d-like game, it’s actually 2d sprite texture attached to 3d object in 3d environment, with camera set-up to orthographic mode with x-angle 45 focusing down. So for this purpose created plane object as a base for game map, but there’s slightly problem as I want to make camera follow the player, but I want the camera to stop when player heading towards the edge of the plane. And I want to make sure the camera was moving only when the player character was back to the camera center, or more like center of viewport, like other typical 2d top-down RPG game. So, the question how to make it possible through either game logic brick or python scripting?

Thank you for any help.

should be easy. have four rays to where the camera should look for a wall, (-)X and (-)Y probably. check for a wall (maybe invisible) in each direction and tell the camera to stop following the axis that has a hit.

also check distance of player on each axis. if player opposite direction of hit ray, follow again.

The simplest way would be to just restrict the camera using the min and max functions based on the player’s position and the bounds of the plane. See this example.

camera_limits.blend (84.6 KB)

Hello. Sorry for late reply. Anyway, when i’m trying to create the ray sensor for the camera, i just found out that it wasn’t work for camera if the camera is parented with player object (or was only me?). so i’m trying to find another solutions to make camera following the player without really parenting to it. also, I’m try to limiting the camera within the plane map using the player world positioning to achieve this. then after a few days of figure out in scripting (I forgot to say that I’m newbie in Python), finally I’m made a script inside blender file that can follow player and limiting camera in 2d game style. But I still need somebody to help reviewing my scripting as if it need the code improvement, because like I say before, I’m newbie in Python, so this is only what I can try to achieve. Thanks.

2d rpg test.blend (973.7 KB)

Thank you for your help. Btw, I’m trying to figure out how to did this with camera with x-angle in 45 above your character with orthographic looking, but seems like the player object move past camera when the object goes either up or down, but it’s no problem when player goes right or left. You can look at my file above to see what I’m trying to achieve.