So that when a player moves, the other player isn’t cut out of the screen?
Similar to Street Fighter fight cam, where it has limits on narrowness and wideness, but so that the players can move around without the position of the other causing problems…
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?
Although I’ve never tried it, I think this should help.
Decide the distance for which the original zoom is to be kept. Let’s assume it to be 300. Also let the zoom stop distance be 600.
Use the condition to check when the X position of Player1 is less than abs(Player2.X() - 300) and add another condition to check if the X position of Player1 is greater than abs(Player2.X() - 600).
For these conditions, set the action to Change camera zoom and set the value equal to 300/(abs(Player1.X() - Player2.X())).
This should solve the zoom out problem.
For stopping the zoom at a point, create another event and set the condition to check when the X position of Player1 is less than abs(Player2.X() - 600).
Set the condition to change camera zoom to 300/600. This will set a fixed value for the zoom. To stop the objects, you can add a force to them in the opposite sides.
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)