title: Unity change camera position with value from another script with functions
body: <p>I am pretty new to Unity and i am trying to understand why this isn't working. What i am trying to do is move the camera with a Vector3.Lerp from the current camera position to the object position. This i want to do from functions in both scripts. Therefore i have two scripts one for the Camera and the other for the Cube.</p>
  
  <p>This is the script for the camera </p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class CameraScript : MonoBehaviour {
  
      private Vector3 positionCamera;
      public Camera camera;
  
      void Start () {
          camera = GetComponent&lt;Camera&gt;();
          positionCamera = camera.transform.position;
      }
  
      void Update () {
          GoToTarget();
      }
  
      public void GoTo(Vector3 position)
      {
          positionCamera = Vector3.Lerp(positionCamera, position, Time.deltaTime);
      }
  
      public void GoToTarget()
      {
          Vector3 newpos = positionCamera;
          camera.transform.position = newpos;
      }
  }
  </code></pre>
  
  <p>And the script for the Cube</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class CubeScript : MonoBehaviour {
  
  
      public CameraScript cameraScript;
      private GameObject cube;
      private Vector3 cubePosition;
      private Vector3 newPosition;
  
      void Start () {
          cameraScript = new CameraScript();
  
          cube = this.gameObject;
  
          cubePosition = cube.transform.position;
          newPosition = transform.position;
  
      }
  
      // Update is called once per frame
      public void Update () {
          UpdatePosition();
      }
  
      public void UpdatePosition()
      {
          if (Input.GetKey(KeyCode.Space))
          {
              cameraScript.GoTo(newPosition);
          }
  
      }
  }
  </code></pre>
  
  <p>I pass the position from the cube script and send it to the GoTo function in the camera script. Then the camera should use the Vector3.Lerp to move the camera to the position of the cube. This however doesn't work. </p>
  
  <p>How can i make this work with functions? 
  Am i using the translate.position correctly for the camera? Or should i assign a game object first?</p>
  
  <p>Thanks</p>