Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GameCamera : MonoBehaviour {
- public GameObject playerObject;
- public float cameraHeight;
- private float scrollVar;
- //zoom changes
- float scrollIn(float x){
- Debug.Log(scrollVar);
- return x --;
- }
- float scrollOut(float x){
- Debug.Log(scrollVar);
- return x ++;
- }
- // Use this for initialization
- void Start () {
- playerObject = GameObject.Find("Player");
- }
- // Update is called once per frame
- void Update () {
- Vector3 new_pos = playerObject.transform.position;
- scrollVar = Input.GetAxis("Mouse ScrollWheel");
- if (scrollVar > 0){
- new_pos.y = new_pos.y - scrollIn(new_pos.y);
- }
- if (scrollVar < 0){
- new_pos.y = new_pos.y - scrollOut(new_pos.y);
- }
- new_pos.y = cameraHeight;
- transform.position = new_pos;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement