Help for dynamic camera following two players

M

m1s3ry

Guest
Hello everyone

I'm trying to make a 2d platform arena shooter multiplayer game, so I want a camera to stay in the middle of the two players. I can do that alright, but I don't know how to make it zoom in or out when the players walk away from each other.

I have an object_camera and the view following it. The code to make it stay in the middle of the two players is this (pretty simple), I just want to make it zoom out if the players are away from each other, and zoom in when the players go closer to each other

STEP from obj_camera

//Stay in the middle of the two players
x = mean(obj_player.x,obj_player_2.x)
y = mean(obj_player.y,obj_player_2.y)

Any help would be really appreciated. Thank you.

GameMaker 1.4
 
C

ChiHelios

Guest
So now you have the average point, you'll want to scale the room using

View_wview
View_hview
Which fit the room you your view port, doing the zoom for you! The documentation is pretty good for these variables, take a look
 
M

m1s3ry

Guest
After all, I found a free dynamic camera asset on GM Market. Can't post links yet because I'm a new user in the forums, but check it out.
 
Top