To center the X position of the camera, you can use the “Camera center X position” action.
To center it between two objects, you can use something similar to this:
This will set the camera position to sum of position of the first object and half of distance between the two objects.
You can also use Player2.X() - abs((Player1.X() - Player2.X())/2) to achieve similar results.
If this causes both your objects to move out of the camera view, you can set a condition that checks the position of one of the objects. For example, check when the X position of Player1 is greater than Player2.X() - 500.
Cool. I used your code, and it does in fact place the camera center between the two objects. Both objects are therefore located outside of the viewscreen at the same time.
The second piece of code affects things. It makes it so the centered camera is centered to a certain point of movement away from the center (by either player). After that point, either player can exit the screen be continuing away from the otherplayer, while the otherplayer remains in the screen.
Is there a way to make the camera zoom, though, so that when the characters get further away, the camera just pans out and they don’t go out of the screen.
Second part: is there a way to after that, make it so the zooming out stops at a specified point (so we don’t get toooo panned out), and at that point the characters are blocked from exiting the screen?
Where the camera causes problems for the user is sometimes, when one player moves away, it just follows that one player, and the other then goes out of the screen. When he goes close again, the camera snaps back to the center position between the two players. There is also a bit of a jolt when it transitions from (initial) camera one to camera two (further away), but after that the transition is smooth when going between one and two and back again (not sure why this is). Also, the camera has the problem of cutting out the y axis when the players step onto new platform heights.
Is there another way to do this, where the first thing would be:
1.center the camera between the two (so it’s always centered)
when less/equal to 600, change zoom to 500
when more/equal to 601, change zoom to (like it is in your code)
Maybe it could work like,
place an (invisible/noninteractive) object equidistant between PlayerOne and PlayerTwo.
set camera zoom to focus on NewObject at distance of two characters + 100 on each side
minimum camera size 500
maximum camera size 1000
I’m not sure if those things are possible, though.
Nice. I also am using Object3 as the camera now (in another question post on this board).
But the next step didn’t get answered yet anywhere. I wonder how to then zoom the camera so it includes the two players whether they’re close or far (still centered on the object between them), and up to a certain point of far or close (so we don’t get too zoomed out)