Advertisement
KorolevDmitry123

Untitled

Jul 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Zoom : MonoBehaviour {
  5. public GameObject camera;
  6. public float speed;
  7. public float flOV;
  8. public float flOV1;
  9. public float deltaZoom;
  10. public bool upZoom;
  11. public bool downZoom;
  12. public float tmp;
  13. public bool a;
  14. void Start()
  15. {
  16. flOV = 30.0f;
  17. upZoom = false;
  18. downZoom = false;
  19. a = false;
  20. }
  21. void Update()
  22. {
  23. camera.GetComponent<Camera>().fieldOfView = flOV;
  24. if (a == true && upZoom == false && downZoom == false)
  25. {
  26. flOV = 99.99f;
  27. }
  28. if (a == false && upZoom == false && downZoom == false)
  29. {
  30. flOV = 30.0f;
  31. }
  32. if (upZoom == true)
  33. {
  34. flOV -= deltaZoom * speed * Time.deltaTime;
  35. if (flOV <= 15.0f)
  36. {
  37. flOV = 15.01f;
  38. }
  39. }
  40. if (downZoom == true)
  41. {
  42. flOV += deltaZoom * speed * Time.deltaTime;
  43. if (flOV >= 100.0f)
  44. {
  45. flOV = 99.99f;
  46. }
  47. }
  48. if (Input.GetMouseButtonDown(1))
  49. {
  50. if (a == true)
  51. {
  52. a = false;
  53. }
  54. else if (a == false)
  55. {
  56. a = true;
  57. }
  58. }
  59. tmp = Input.GetAxis("Mouse ScrollWheel");
  60. if (tmp > 0.0f)
  61. {
  62. upZoom = true;
  63. }
  64. if (tmp < 0.0f)
  65. {
  66. downZoom = true;
  67. }
  68. else if (tmp == 0.0f)
  69. {
  70. upZoom = false;
  71. downZoom = false;
  72. }
  73. }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement