Sorry, I sort of make it work by clamping the position.x of camera. But now I have another related question - How can I stop my characters to go out of camera view
Some background on this project:
I'm making a "3D" fighting game and now trying to figure out how fighting game's camera works. I based my project on Street Fighter 6 camera. It is not a true 3D camera eg. no need for camera rotation, just move x,y and a bit of z
I have orthogonal camera3D following the center of the screen (+). It expands the view based on the length between the fighters then I clamp the camera max/min size.
cam.size = lerp(cam.size + cam_size, (p1.global_position.x-p2.global_position.x)/2, 0.5)
if cam.size < 5.2:
cam.size = 5.2
if cam.size > 6.7:
cam.size = 6.7
But during Maximum view each fighters still able to move out of the camera's view left and right. How can I stop them from moving out of view? (In the game the fighter will just keep playing "waking back" animation but never leave the view)