Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Dec 16, 2016 at 03:17 PM by Vylax for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Vylax · Dec 16, 2016 at 03:01 PM · gameobjecterror messagearray of gameobjectsarraylist

BCE0019: 'gameObject' is not a member of 'Object'.

Searched in sames question but didn't found my case... here's the code:

 var closeEnemies : Array = new Array(); 
 //...
     for(var i : int = 0; i < closeEnemies.length + 1; i++) {
         if(closeEnemies[i] != null) {
         closeEnemies[i].gameObject.GetComponent(enemy).health -= damage;
         }else{
             i++;
         }
     }
 //...
 function OnCollisionEnter2D (other : Collision2D) {
     if(other.gameObject.GetComponent(friendly).status == "Enemy" && ownCase.GetComponent(Case).empty == false) {
     y += 1;
     other.gameObject.GetComponent(numbers).x = y;
     closeEnemies[other.gameObject.GetComponent(numbers).x] = other.gameObject;
     }
 }
 
 function OnCollisionExit2D (other : Collision2D) {
     if(other.gameObject.GetComponent(friendly).status == "Enemy" && ownCase.GetComponent(Case).empty == false) {
   closeEnemies[other.gameObject.GetComponent(numbers).x] = null;
     }
 }

As you can see closeEnemies is an Array wich I stock colliding gameObjects in.

I tried a lot of things but I still get BCE0019: 'gameObject' is not a member of 'Object'. error...

What's wrong with the script ?

Thx for your help.

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by tanoshimi · Dec 16, 2016 at 03:09 PM

This line right at the top:

 var closeEnemies : Array = new Array(); 

You don't specify what closeEnemies is an array of. So its elements are all just generic "Objects". And as the error messages states, objects don't have a .gameObject property.

I don't use Javascript, but I assume you meant something like:

 var closeEnemies : 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 Vylax · Dec 16, 2016 at 03:17 PM 0
Share

Thank you, you're the fastest !!!

Follow this Question

Answers Answers and Comments

77 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Array of objects works half the time! 0 Answers

Unity bug gives false error messages or doesen't work without a Debug.Log() line present 1 Answer

how to save positions in Vector3 Array und move playerobjekt to the saved position in array's?? 1 Answer

var script : GameObject 2 Answers

MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. 2 Answers


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