- Home /
Error CS0101 in C#
Started coding a door script for an animation that happens when the door's box collider is triggered. I figured I would watch a tutorial video on it (it was this video: https://www.youtube.com/watch?v=iKWJBgFCDWU) and follow along since I did not know how to do it initially. Turns out, I did not do it right, and even looking through and copying EXACTLY what the video stated, I still got an error message. Here is the code that I wrote:
public class Door : MonoBehaviour {
private Animator _animator;
// Use this for initialization
void Start () {
_animator = GetComponent<Animator>();
}
void OnTriggerEnter(Collider other)
{
if(other.tag == "Player")
{
GetComponent<Animator>().SetBool("Open", true);
}
}
}
This code is producing the error: Door.cs(1,10): error CS0101: The namespace 'global::' already contains a definition for 'Door'
I have no idea what this means. If somebody could potentially figure out this error (since I cannot go into play mode until this is solved) or maybe give me a new video that might not produce this error, then I would be very grateful.
you have multiple Door clases inside unity, you need to delete one (maybe it got duplicated)
Answer by Jao_Preto · Apr 11, 2019 at 05:53 PM
Hello man,
Maybe there is already some NameSpace(in some script) in your all project called "Door", and that causing some conflict with your script. I saw the video and he created the script with name "DoorScript" instead "Door" as you did. Try to change your script's name to "DoorScript" or something that isn't "Door". Maybe it works :x
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to create a shop system? 0 Answers
Unloading Broken Assembly | How to solve this !? 2 Answers
how to do a simil RE7 door system 0 Answers