- Home /
error: namespace already contains definition
I keep getting a report saying Assets/Scripts/Ships/MissileLancher.js(9,6): BCE0132: The namespace '' already contains a definition for 'guntype'.
it has only one definition help?
var reloadtime : float;
var shot : GameObject;
var numshots : int;
var au : Object;
private var Target : GameObject;
enum guntype{
singlefire,
rapidfire,
}
function ChangeTarget(t : GameObject){
Target = t;
}
var gunType : guntype;
private var loaded : boolean = true;
private var fireing : boolean = false;
private var t : Transform;
function Start(){
t = transform;
au = audio;
}
function FireCheck(){
switch(gunType){
case guntype.singlefire:
if (loaded){Fire();}
break;
case guntype.rapidfire:
if (loaded){Fire();}
break;
}
}
function Fire(){
var s : GameObject;
switch(gunType){
case guntype.singlefire:
s=Instantiate(shot,t.position,t.rotation);
s.SendMessage("ChangeTarget",Target,SendMessageOptions.DontRequireReceiver);
au.Play();
loaded = false;
yield WaitForSeconds(reloadtime);
loaded = true;
break;
case guntype.rapidfire:
for (i=1;i < numshots; i++){
s=Instantiate(shot,t.position,t.rotation);
au.Play();
yield WaitForSeconds(0.15);
}
loaded = false;
yield WaitForSeconds(reloadtime);
loaded = true;
break;
}
}
thanks
I have the same error but for the first person camera. Help?
Help with what? As aldonaletto said, this error indicates a duplicated script name somewhere in your project. You'll have to fix that.
Answer by aldonaletto · Jul 14, 2011 at 01:44 AM
I placed this script in my project, and had no errors. It seems you have another script (maybe an old version of this one) with guntype defined elsewhere in your project, and it's causing the error. Both scripts probably are in the same folder - I tried this, and only had errors when both scripts were compiled together.
oh, I have a laser cannon using guntype in the same folder mabey thats it lol
Aha! I knew it! (I had the same problem once...) Well, if this solved your problem, please click the "check" button below the voting thumbs (in the answer), so the question is marked as solved and may help others with a similar problem.
well I'm coding Stats for an RPG, so far I have "intellect", "charisma" Strength" etc. Anyways I have set a base class so my other classes like a Rogue or Hunter can inherit from it. $$anonymous$$y base class has: public int Sta$$anonymous$$a { get{return Sta$$anonymous$$a;} set{Sta$$anonymous$$a = value;} }
And my Rogue class has: Sta$$anonymous$$a = 20; I don't see why this is a problem because "value" is a variable right, and in my Rogue class sets the value for that variable. Please help.
Your answer
Follow this Question
Related Questions
Necessary to remove unused scripts from imported packages for deployment? 1 Answer
FPS Gun Script Definition error 1 Answer
C# Visual Basic Error 1 Answer
UnityEngine.dll doesn't fix namespace error? 1 Answer
Using Namespaces? 1 Answer