Advertisement
GWibisono

3. How to make a 2D Game - Unity 4.3 Tutorial

May 7th, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //best thanks to https://www.youtube.com/channel/UCjWeE1oMa9SKWUSdx0LzcRw
  2.  
  3. //move all to the place
  4.     topWall.size = new Vector2( mainCam.ScreenToWorldPoint ( new Vector3(Screen.width * 2f,0f,0f )).x,1f  );
  5. //center
  6. //  topWall.center = new Vector2( 0f, mainCam.ScreenToWorldPoint ( new Vector3( 0f, Screen.height, 0f)).y + 0.5f );
  7.   topWall.offset = new Vector2 (0f, mainCam.ScreenToWorldPoint (new Vector3 ( 0f, Screen.height, 0f)).y + 0.5f);
  8.  
  9.  bottomWall.size = new Vector2 (mainCam.ScreenToWorldPoint (new Vector3 (Screen.width * 2, 0f, 0f)).x, 1f);
  10.  bottomWall.offset = new Vector2 (0f, mainCam.ScreenToWorldPoint (new Vector3( 0f, 0f, 0f)).y - 0.5f);
  11.  
  12.  leftWall.size = new Vector2(1f, mainCam.ScreenToWorldPoint(new Vector3(0f, Screen.height*2f, 0f)).y);
  13.  leftWall.offset = new Vector2(mainCam.ScreenToWorldPoint(new Vector3(0f, 0f, 0f)).x - 0.5f, 0f);
  14.  
  15.  rightWall.size = new Vector2(1f, mainCam.ScreenToWorldPoint(new Vector3(0f, Screen.height*2f, 0f)).y);
  16.  rightWall.offset = new Vector2(mainCam.ScreenToWorldPoint(new Vector3(Screen.width, 0f, 0f)).x + 0.5f, 0f);
  17.  
  18.  //note how it is offset and not center
  19.  //Move the players to a fixed distance from the edges of the screen:
  20.  Player01.position.x = mainCam.ScreenToWorldPoint (new Vector3 (75f, 0f, 0f)).x;
  21.  Player02.position.x = mainCam.ScreenToWorldPoint (new Vector3 (Screen.width -75f, 0f, 0f)).x;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement