I know I need to force cast this line but don’t know how
for ( var checkDoor : GameObject in cells*.GetComponent(AIPathCellScript).doors)*
// have tried this
for ( var checkDoor : GameObject in (cells*.GetComponent(AIPathCellScript)as AIPathCellScript).doors)*
// and also this
for ( var checkDoor : GameObject in cells*.GetComponent.().doors)*
and still coming out with the same error, Any Help would be greatly apperciated.
What’s cells ? From the error message, I suspect that it’s an Array (Array class, not builtin array): Array elements are defined as Object, the variant type that can hold values of any type. If this is the case, you should first get the cells element in a GameObject variable (supposing that each cell element is a GameObject), get the doors array reference and then enter the loop:
var cell: GameObject = cells*;*
var doors: GameObject[] = cell.GetComponent(AIPathCellScript).doors;
for (var checkDoor: GameObject in doors){
//
}
Answer from a noob: is the content of the cells array a list of prefabs? If so, of course it happens because GetComponent is avaiabile only for GameObject and Component instances.
Try to initiazlize the objects as GameObject using the method
list *= Initialize(Object object, Vector3 position, Quaternion.identity);*
and then use GetComponent. It should work