• Advertisement
Sign in to follow this  

Lock Camera Issues

This topic is 1274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am coding a lock camera like the one in Zelda for my game but has some issues. 


1. Camera Pitch


I use a traditional equation to calculate the ideal position of third person camera as follows:

camera_pos = focal_pos - camera_dir*zoom_distance

The focal position is the middle point between the player character position and the target position.


The zoom distance is calculated as follows:

zoom_distance = distance(focal_pos, player_pos)+min_zoom

Regarding the camera direction, because the game is third person shooter, the camera is put closer to the player character than Zelda but still keeps similar composition that the player character is on the right side of the screen and the target is on the left side or vice versa. Anyway, the camera yaw is calculated as follows:

camera_yaw = vector_to_yaw(target_pos - player_pos) + yaw_bias

This equation is just an experiment and it has an issue that the yaw bias needs to be adjusted or the position of the player character on the screen is influenced by the distance between the player character and the target.


My issue is that I haven't come up with a solid solution to calculate the camera pitch that can keep the player character and the target on the screen. Would anyone please give me some idea?


2. Camera Collision


So far I learned there are two solutions to camera collision, collision zoom and physical collision model, from Third Person Camera Navigation in Game Programming Gem 4. When you rotate the camera while locking on something in Twilight Princess, you may notice that the camera has jump cut if it hits a wall. So it looks like they adopted the method of collision zoom. Then my issue is how to make collision zoom work with the lock camera. If it is the normal camera and focus is on the player, then you can cast a ray from the player position to the camera. It works because the player has its own collision shape and is never inside a wall. However, in case of lock camera, the focal point could be inside something in a level, which causes wrong results from ray casting. Moreover, making the camera jump closer to the focal point could make the player out of the screen.


So I use a method that the camera will simply jump toward the player character instead of the focal point. You can think of the result from the fore-mentioned equations as an ideal position of the camera. The final position is the one adjusted by collision zoom. So I need to adjust the camera direction to re-orientate it toward the focal position if it hits a wall. This adjustment may cause oscillation of camera direction in some cases.


However, I don't think they used that method in Twilight Princess. If the lock camera hits a wall in Zelda, sometimes it still can keep a nice composition that the player character and the target is on the opposite side of the screen. Does anyone has idea what method they might use? And if you have other solution to camera collision, please share with me. Thanks for help.

Edited by isatin

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement