- Home /
 
 
               Question by 
               Hgsc45 · Jun 12, 2017 at 09:13 AM · 
                cameracamera-movementcameras  
              
 
              Unity 5 3D Camera scrolling script not correctly placed
I have a C# code shown below which lets me scroll my player camera in and out with a limited distance, but for some reason spawns the camera far below the player. I am new to Unity and don't have any idea how to solve this.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Camera : MonoBehaviour {
 public Transform playerCam;
 private float zoom;
 public float zoomSpeed = 2;
 public float zoomMin = -2f;
 public float zoomMax = -10f;
 // Use this for initialization
 void Start () {
     zoom = -3;
     
 }
 
 // Update is called once per frame
 void Update () {
     zoom += Input.GetAxis ("Mouse ScrollWheel") * zoomSpeed;
     if (zoom > zoomMin)
         zoom = zoomMin;
     if (zoom < zoomMax)
         zoom = zoomMax;
     playerCam.transform.position = new Vector3 (0, 0, 0);
 }
 
               }
Please Help!
Thanks, Hgsc45
               Comment
              
 
               
              Your answer