How to get my cameras x position in between player1 and player2?

I want my camera to stay at the center point of my 2 players. The game is running in 2D and the movement takes place on the X Axis.

function Update ()
{
	if (ActualLevelSettings.player1 == true && ActualLevelSettings.player2 == false)
	{
		transform.position.x = hero1.transform.position.x;
	}
	else if (ActualLevelSettings.player1 == true && ActualLevelSettings.player2 == true)
	{
		transform.position.x = hero1.transform.position.x + hero2.transform.position.x / 2;
	}
}

To get the camera’s x to be in between the x of the two players, you have to add half the difference between hero1 and hero2, not just half of hero2. So it should be:

transform.position.x = hero1.transform.position.x + (hero2.transform.position.x - hero1.transform.position.x) / 2;

Try that.

(Sorry about the editing, my first reply was incorrect)

transform.position.x = (hero1.transform.position.x + hero2.transform.position.x) / 2;