Setting points of edge collider 2D from script
I have a small Pong clone (very new to game dev, but not so new to programming in general). I have it working, and I use two edge colliders as my "goals" on the left & right side, to count score and destroy balls that go off-screen. But now I want to make the colliders' position dynamic, so when I change aspect ratio or resolution, they stick to the sides of the visible screen and not stay in the spot I put them for 1024x768. So I have this piece of code:
Vector3 upperCorner = new Vector3 (Screen.width, Screen.height, 0.0f);
Vector3 maxDimensions = cam.ScreenToWorldPoint (upperCorner);
leftGoal.points.SetValue (new Vector2 (-maxDimensions.x, maxDimensions.y + 1), 0);
leftGoal.points.SetValue (new Vector2 (-maxDimensions.x, -maxDimensions.y - 1), 1);
That doesn't work. It gives me no errors, no warnings, but the collider (named here leftGoal) stays in the default position. This code is being run from the Start() method of a GameController class which keeps track of score, ball spawning etc. so the script is being executed.
Comment
Your answer