- Home /
AI Pathfinding BCE0019: 'GetComponent' is not a member of 'Object'.
I'm developing a map for pathfinding AI in my mobile game, and i'm really getting confused to fix this error " BCE0019: 'GetComponent' is not a member of 'Object'. " it works fine in PC, Mac & Linux development build but i keep on getting errors when i'm running it in an android development build. can someone pls help me, i've tried everything but i can't really fix it. here's the code:
for (stage = 2; stage <= cells.length; stage++)
{
for (i = 0; i <= cells.length - 1; i++)
{
if (doorsToCells[i] == stage - 1)
for (var checkDoor : GameObject in cells[i].GetComponent(AIpathCellScript).doors)
{
if (checkDoor != gameObject)
{
for (var checkCell : GameObject in checkDoor.GetComponent(AIpathDoorScript).imediateCells)
{
for (var j : int = 0; j <= cells.length - 1; j++)
{
if (cells[j] == checkCell && doorsToCells[j] == null)
doorsToCells[j] = stage;
}
}
}
}
}
}
testForCells = false;
}
waitToTestCells -= 1;
}
please help :(
When asking for help with script errors it's really really really good form to post the line number where the compiler found the error. Otherwise us guys have to read the code line by line trying to see what the compiler sees.
What is the type for the cells
array. $$anonymous$$aybe it's untyped?
Answer by Xtro · Jul 31, 2013 at 08:57 PM
If you store gameobjects in the array, you should cast cells[i] to GameObject
((GameObject)cells[i]).GetComponent(.......);
if your cells array is storing unity component objects then you should cast accordingly
((Component)cells[i]).GetComponent(.......);
I don't know what type is your cells array.
Your answer
Follow this Question
Related Questions
Plese help me guys! BCE0019: 'GetComponent' is not a member of 'Object'. 1 Answer
My question is how to give a newly made prefab a location target. 2 Answers
What path-finding technique do I use? 2 Answers
Alternative to remainingDistance (Entire Path Calculation)? 0 Answers
Path finding algorithm for 2d game 2 Answers