Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GameCamera : MonoBehaviour {
  6.  
  7. public GameObject playerObject;
  8.  
  9. public float cameraHeight;
  10.  
  11. private float scrollVar;
  12.  
  13. //zoom changes
  14. float scrollIn(float x){
  15.  
  16. Debug.Log(scrollVar);
  17.  
  18. return x --;
  19. }
  20.  
  21. float scrollOut(float x){
  22.  
  23. Debug.Log(scrollVar);
  24.  
  25. return x ++;
  26. }
  27.  
  28. // Use this for initialization
  29. void Start () {
  30.  
  31. playerObject = GameObject.Find("Player");
  32. }
  33.  
  34. // Update is called once per frame
  35. void Update () {
  36.  
  37. Vector3 new_pos = playerObject.transform.position;
  38.  
  39. scrollVar = Input.GetAxis("Mouse ScrollWheel");
  40.  
  41. if (scrollVar > 0){
  42.  
  43. new_pos.y = new_pos.y - scrollIn(new_pos.y);
  44. }
  45.  
  46. if (scrollVar < 0){
  47.  
  48. new_pos.y = new_pos.y - scrollOut(new_pos.y);
  49. }
  50.  
  51. new_pos.y = cameraHeight;
  52.  
  53. transform.position = new_pos;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement