- Home /
ERROR : QUACK is not a generic definition. What now?
var enemyUnit : GameObject[];
var enemyAIScript : EnemyAI[];
var enemyHuntScript : EnemyHunt[];
function Start(){
//Line18 enemyUnit = GameObject.FindGameObjectsWithTag("Enemy");
//Line19 enemyAIScript = enemyUnit.GetComponent.<EnemyAI>();
enemyHuntScript = enemyUnit.GetComponent.<EnemyHunt>();
alert = false;
caution = false;
normal = true;
}
Help. I was just doing my thing editing a script when I got the error in the console
Enemies/RegularUnits/ControlAI.js(19,43): BCE0138: 'quack' is not a generic definition.
What do I do ? I dont even have anything called quack in my script
It's probably because you've set up all your variables as arrays, and are trying to use generics to assign single instances to them.
I think this script is totaled. Start with something simpler in a fresh project, see all the easy errors and how to fix, and work your way up. The first few things you make are always going to be just for learning.
Quack? What are you following that would even have a quack in it? So you can tell other people to avoid it.
The "quack" is due to the nature of the error. Javascript, by default, uses Duck Typing, which is often summarised as "if it quacks like a duck, it's a duck". By using generics, you're enforcing hard types, rather than allowing duck typing to work properly. Since those types don't match, the duck typing in the compiler can't unify the two types (it can't deter$$anonymous$$e how to make the object "quack"), so it throws an error.
Answer by DRProductions · Feb 10, 2015 at 02:40 AM
You've declared all your variables as if they were arrays and then you tried to acess them like they weren't. Remove the [] after your variable types. eg, its not enemyunit : GameObject[] its enemyunit : GameObject OR acess your arrays properly. instead of saying enemyunit.Getcomponent say enemyunit[Insert index number here].getcomponent