I was looking at a pong tutorial online and I noticed that If I put the boarders for the game inside of function update, then they would overlap each other and THEN readjust, so the ball would hit both colliders and you would have one point for each player. So I changed function Start to function Update and then the Player(the pong bars) would not readjust with the camera like its supposed to with ScreenToWorldPoint. So why is this. Why can’t I just put the have “Player01.position.x = mainCam.ScreenToWorldPoint()” inside function Start()?
function Start ()
{
topWall.size = new Vector2 (mainCam.ScreenToWorldPoint (new Vector3 (Screen.width *2, 0f, 0f)).x, 1f);
topWall.center = new Vector2(0f, mainCam.ScreenToWorldPoint(new Vector3 (0f, Screen.height, 0f)).y + .5f);
bottomWall.size = new Vector2 (mainCam.ScreenToWorldPoint (new Vector3 (Screen.width * 2f, 0f, 0f)).x, 1f);
bottomWall.center = new Vector2(0f, mainCam.ScreenToWorldPoint(new Vector3 (0f, 0f, 0f)).y - .5f);
leftWall.size = new Vector2 (1f, mainCam.ScreenToWorldPoint (new Vector3 (0f, Screen.height * 2f, 0f)).y);
leftWall.center = new Vector2(mainCam.ScreenToWorldPoint(new Vector3 (0f, 0f, 0f)).x - .5f, 0f);
rightWall.size = new Vector2 (1f, mainCam.ScreenToWorldPoint (new Vector3 (0f, Screen.height * 2f, 0f)).y);
rightWall.center = new Vector2(mainCam.ScreenToWorldPoint(new Vector3 (Screen.width, 0f, 0f)).x + .5f, 0f);
}
function Update ()
{
Player01.position.x = mainCam.ScreenToWorldPoint (new Vector3 (75f, 0f, 0f)).x;
Player02.position.x = mainCam.ScreenToWorldPoint (new Vector3 (Screen.width - 75f, 0f, 0f)).x;
}