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 /
avatar image
0
Question by rizkyjr1 · May 11, 2016 at 12:05 AM · c#scripting problemscript error

Hi, I have two errors. I am sorry everyone but I am going crazy

CS0118, DestroyByContact.Game controller' is a field' but a type' was expected and CS10621, Type object' does not contain a definition for GameOver' and no extension method GameOver' of type `object' could be found (are you missing a using directive or an assembly reference?). Here is my script { public GameObject explosion; public GameObject playerExplosion; private object Gamecontroller; private object gamecontroller;

 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Boundary")
     {
         return;
         Debug.Log(other.name);
     }
     
     Instantiate(explosion, transform.position, transform.rotation);
     if (other.tag == "Player")
     {
         if ((playerExplosion != null) && (gamecontroller != null))
         {
             Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
             Gamecontroller.GameOver();
             gamecontroller = GameObject.GetComponent<Gamecontroller>();
         }
         Destroy(other.gameObject);
         Destroy(gameObject);
     }
 }

}

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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TBruce · May 11, 2016 at 12:41 AM

@rizkyjr1

Both Gamecontroller and gamecontroller are plain UnityEngine objects. They are not components. The first thing you need to do is to replace private object with whatever components they are.

Comment
Add comment · Show 9 · 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 rizkyjr1 · May 11, 2016 at 01:04 AM 0
Share

I am sorry @$$anonymous$$avina could you be a little more specific?

avatar image TBruce rizkyjr1 · May 11, 2016 at 01:23 AM 0
Share

@rizkyjr1

You have these two declarations

 private object Gamecontroller;
 private object gamecontroller;

But you are trying to use them like this

 Gamecontroller.GameOver();

GameOver is not a member of object

and then you are doing this

 gamecontroller = GameObject.GetComponent();

a) In your code you made Gamecontroller a variable but you are using it as a type in the GetComponent() statement.

b) GetComponent() returns component of Type type if the game object has one attached

c. I do not know what you intentions are with these calls but they may eventually lead to errors as well

 Destroy(other.gameObject);
 Destroy(gameObject);

I am just pointing out the errors here. I can not give you specifics on what this should be

 private object Gamecontroller;
 private object gamecontroller;

but let me just say it should look something like this

 private [Your Component Here] Gamecontroller;
 private [Your Component Here] gamecontroller;

for example

 private $$anonymous$$yGameController Gamecontroller;
 private $$anonymous$$yGameController gamecontroller;

Place the class name that has the function GameOver() defined in it in place of $$anonymous$$yGameController.

avatar image rizkyjr1 TBruce · May 11, 2016 at 01:51 AM 0
Share

Hey, it is fixed but there is another error CS1061 GameObject' does not contain a definition for gameControllerGameOver' and no extension method gameControllerGameOver' of type `UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?) { public GameObject explosion; public GameObject playerExplosion;

 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Boundary")
     {
         return;
     }
     Instantiate(explosion, transform.position, transform.rotation);
     if (other.tag == "Player")
     {
         Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
         gameObject.gameControllerGameOver (); line 19<
     }
     Destroy(other.gameObject);
     Destroy(gameObject);
 }

}

Show more comments
avatar image TBruce rizkyjr1 · May 12, 2016 at 12:43 AM 0
Share

@rizkyjr1

Please click the tick to accept the answer if your question was answered.

avatar image rizkyjr1 TBruce · May 12, 2016 at 02:10 AM 0
Share

Hi, could you help me with the above situation? please, I can not find anything wrong.

Show more comments

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

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

Related Questions

Help with Script 0 Answers

Parse issue, despite the data being pulled from database 2 Answers

c# - error CS0103: The name `hit' does not exist in the current context (cardboard switching) 1 Answer

Weapon Swap loop only one way. Any ideas? 0 Answers

Errors in script when trying to play animation clips 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