Advertisement
Guest User

issue

a guest
Jul 25th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1.  
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class MinimapCamera : MonoBehaviour {
  6.  
  7. public static int zoomLevel; //zoom level
  8. public static MinimapCamera Instance; //declare this to global script
  9.  
  10.  
  11. //Private variable
  12. private int zoomCurrent;
  13.  
  14. [HideInInspector]
  15. public Transform Target;
  16.  
  17. void Start()
  18. {
  19. //Setting Default Value
  20. zoomLevel = 3;
  21. zoomCurrent = zoomLevel;
  22. Instance = this;
  23. GameObject hero;
  24. hero = GameObject.FindGameObjectWithTag("Player");
  25. Target = hero.GetComponent<Transform>();
  26. }
  27.  
  28. // Update is called once per frame
  29. void Update () {
  30.  
  31. //Follow player
  32. transform.position = new Vector3(Target.position.x,transform.position.y,Target.position.z);
  33. ZoomManage ();
  34.  
  35. }
  36.  
  37. void ZoomManage ()
  38. {
  39. //Check zoom limit
  40. if(zoomLevel < 0)
  41. {
  42. zoomLevel = 0;
  43. }else if(zoomLevel > 4)
  44. {
  45. zoomLevel = 4;
  46. }
  47. }
  48.  
  49. public void ZoomUpdate()
  50. {
  51. if(zoomLevel < zoomCurrent)
  52. {
  53. this.GetComponent<Camera>().orthographicSize += 3;
  54. zoomCurrent = zoomLevel;
  55. }else
  56.  
  57. if(zoomLevel > zoomCurrent)
  58. {
  59. this.GetComponent<Camera>().orthographicSize -= 3;
  60. zoomCurrent = zoomLevel;
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement