Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

LookAtCameraYonly causing issues

Discussion in 'Scripting' started by hmacyt, Aug 11, 2010.

  1. hmacyt

    hmacyt

    Joined:
    Jul 1, 2010
    Posts:
    203
    Code (csharp):
    1. using UnityEngine;
    2.  using System.Collections;
    3.  
    4.  public class LookAtCameraYonly : MonoBehaviour
    5.  {
    6.     public Camera cameraToLookAt;
    7.  
    8.     void Update()
    9.     {
    10.         Vector3 v = cameraToLookAt.transform.position - transform.position;
    11.         v.x = v.z = 0.0f;
    12.         transform.LookAt(cameraToLookAt.transform.position - v);
    13.     }
    14.  }
    Code (csharp):
    1. Assets/Standard Assets/Scripts/Testing/LookAtCameraYonly.cs(4,15): error CS0101: The namespace `global::' already contains a definition for `LookAtCameraYonly'
    2.  
    Its causing my first person controller prefab to break once I save and reload, any ideas?
     
  2. menneske

    menneske

    Joined:
    Jan 23, 2009
    Posts:
    44
    Thats an error I usually get when I open a script and edit it, then go to unity and re-organize my assets, then continue editing the script (which I moved) and saving.

    Then I end up having two scripts, because the script editor saves to the old location.

    Try to see if you have more than one file for that class.
     
  3. hmacyt

    hmacyt

    Joined:
    Jul 1, 2010
    Posts:
    203
    whatever I did messing with the files (copy, pasting, deleting) worked, thanks :D