So im working on a 2d 2player student project, we are trying to have a camera that tracks both players.
Atm ive worked out how to keep the cam in the middle of the players but as for the cam distance its been a little tricky trying to work it out.
the code isent the most elegant so far but it does the job
var player1 : Transform;
var player2 : Transform;
function Update ()
{
var sum1 : float;
var sum2 : float;
var sum3 : float;
var sum4 : float;
sum1 = player1.position.x + player2.position.x;
sum2 = sum1 / 2;
transform.position.x = sum2;
sum3 = player1.position.z + player2.position.z;
sum4 = sum3 / 2;
transform.position.z = sum4;
}
If someone could point me in the right direction it would be much appreciated