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 Severok · Dec 29, 2014 at 09:31 PM · setactive

SetActive(true) dont work

Hi! Its code work, after collision game object deactivated

 void OnTriggerEnter2D (Collider2D col) {
         if (col.gameObject) 
         {
             col.gameObject.SetActive(false);
         }
     }

but this code dont work, why?

 void OnTriggerEnter2D (Collider2D col) {
     if (col.gameObject) 
     {
         col.gameObject.SetActive(true);
     }
 }

how to have it to activate game object?

Sorry for my English and thanks 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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by YoungDeveloper · Dec 29, 2014 at 09:35 PM

SetActive(false) disables the gameObject, which result in inactive update, ontrigger and all other update methods, so you will not be able to check anything from that gameobject updates such as collison and so on. This is a very old question and has been answered hundreds of times. Just do a quick google search and you will have tons of answers.

https://www.google.lv/search?q=unity+setactive+doesnt+work&ie=utf-8&oe=utf-8&gws_rd=cr&ei=BcmhVPWnEcj8ygOx04GICw#q=unity+setactive+doesn%27t+work&spell=1

cheers

Comment
Add comment · Show 2 · 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 Severok · Dec 29, 2014 at 09:52 PM 0
Share

Tnx. I asked a question Google, but got no response, how to enable a game object after the collision.

avatar image Severok · Dec 29, 2014 at 09:56 PM 0
Share

I got it. I'm cant find a collision, if the gameobject is deactivated ...

avatar image
0

Answer by AcE_fLoOdEr · Dec 29, 2014 at 10:15 PM

Here is how you do it:

 GameObject object;
 
 void Start()
 {
    // this will set an instance of the gameobject to your variable
    object = GameObject.Find("Your object's name");
 }

you can now use that GameObject variable to activate/deactivate at any time.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

physics.OverlapSphere colliders 1 Answer

Alternatives to GameObject.SetActive(...) 2 Answers

Conflicting Box Colliders 0 Answers

C# iOS - .active, SetActive(false) 0 Answers

How do I alter all children of a gameobject at once? 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