Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ivan12948 · Sep 19, 2012 at 05:22 PM · objectgetcomponentnotmember

getcomponent' is not a member of 'object'

getting this error whan compiling on android, but works fine on windows. please give me some alternative way to correct this error. tnx.

for (var checkDoor : GameObject in cells[i].GetComponent(AIpathCellScript).doors)

Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SarperS · Sep 19, 2012 at 05:23 PM 0
Share

What is the variable type of cells array? If you haven't explicitly given it a type, you should give it the type GameObject, Android forces strict program$$anonymous$$g, compiler won't choose a type for you and select Object as it's type most of the time. You can also put #pragma strict at the top of each javascript to encounter same errors before switching the project to Android.

avatar image whydoidoit · Sep 19, 2012 at 05:23 PM 0
Share

Put #pragma strict at the top of your files and it will tell you what variables you haven't defined - this is necessary for droid but not for windows. What is cells defined as?

avatar image Khada · Sep 19, 2012 at 05:30 PM 0
Share

Also, is 'GetComponent(AIpathCellScript).doors' a GameObject? That's how you're treating it.

avatar image ivan12948 · Sep 19, 2012 at 05:31 PM 0
Share

var cells = new Array();

avatar image ivan12948 · Sep 19, 2012 at 05:32 PM 0
Share

this is the full code. can you do something about it?

var cells = new Array();

var doorsToCells = new Array();

var imediateCells = new Array();

var testForCells : boolean = true; //

var waitToTestCells : float = 2; //

var stage : int = 1;

@HideInInspector

var doorOpen : boolean = true;

function Awake ()

{

 doorOpen = true;


 cells = GameObject.FindGameObjectsWithTag("AIpathCell"); 


 doorsToCells.length = cells.length; //


 testForCells = true;  


 waitToTestCells = 2;


 stage = 1;


}

function Update ()

{

 if (testForCells && waitToTestCells <= 0)                    


 {                                        


     for (var imediateCell : GameObject in imediateCells)    


     {


         for (var i : int = 0; i <= cells.length - 1; i++)  


         {


             if (cells[i] == imediateCell)     //


                 doorsToCells[i] = 1;


         }


     }                                                      








     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;














}

function OnTriggerEnter (other : Collider)

{

 if (other.tag == "AIpathCell")


     imediateCells.Add(other.gameObject);


}

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Eric5h5 · Sep 19, 2012 at 05:35 PM

Presumably your "cells" array is done with the JS Array class, or possibly an ArrayList. It will make things faster and easier if you ditch the Array class (and ArrayList) and always use built-in arrays or generic Lists instead.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by SarperS · Sep 19, 2012 at 05:36 PM

You should use built in arrays instead of the Array class if you don't need to resize them in realtime. And in that case you can use Generic lists. So use this;

 var doorsToCells : GameObject[];
 var imediateCells : GameObject[];
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ivan12948 · Sep 19, 2012 at 05:49 PM 0
Share

this is the whole code, can you do something here? var cells = new Array ();
var doorsToCells = new Array(); var imediateCells = new Array(); var testForCells : boolean = true; // var waitToTestCells : float = 2; // var stage : int = 1; @HideInInspector var doorOpen : boolean = true;

 function Awake ()
 {
     doorOpen = true;
     cells = GameObject.FindGameObjectsWithTag("AIpathCell"); 
     doorsToCells.length = cells.length; //
     testForCells = true;  
     waitToTestCells = 2;
     stage = 1;
 }

 function Update ()
 {
     if (testForCells && waitToTestCells <= 0)                    
     {                                                                
         for (var imediateCell : GameObject in imediateCells)  
         {
             for (var i : int = 0; i <= cells.length - 1; i++)  
             {
                 if (cells[i] == imediateCell)   
                     doorsToCells[i] = 1;
             }
         }                                                      
         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;




 }
 function OnTriggerEnter (other : Collider)


 {
     if (other.tag == "AIpathCell")

         imediateCells.Add(other.gameObject);
 }

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Script stops working when switching to Android 1 Answer

How can i get a Transform component from an other object's script? 1 Answer

Object Refererence not set yada yada... 2 Answers

How do I change Sprites (and manipulate the Sprite Object) in C#? 0 Answers

Animating an object so it doesn't bounce to the initial location the animation was recorded 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges