I’d like to center the camera on two players. But i can’t understand how.

Players are car1 and car2 in a city, and they can go in every direction (Up - Down - Left- Right)

Probably i’d put camera on a car1, and check if a car2 is into the camera, and if car2 go out, modify the zoom camera. But how ? And, is the better solution ?

Thanks

I suppose that you have to calculate the distance car and the center point between the cars.

Then put the camera on the center point and calculate the zoom based on the distance. ( II don’t know the formula but I suppose it’s easy to find it with same test)

Hi!

To find the center point between the two players, you can use something like: X_Camera = (X_Player1 + X_Player2) / 2 and Y_Camera = (Y_Player1 + Y_Player2) / 2

For the distance:

abs (X_Player1 - X_Player2) + abs (Y_Player1 - Y_Player2)

I think you can use lerp function