Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Joe Long · Jul 24, 2015 at 09:47 PM · disableenablebugsissuespolygon collider 2d

[Solved] Bug with disabling Polygon Collider 2D

When i tried to set my polygon Collider 2d to disabled (enabled = false), it would never disable for me. Had to instead just destroy the poly collider. Does anyone else have this issue?

Comment
Add comment · Show 4
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 fuego_see_money · Jul 24, 2015 at 09:49 PM 0
Share

Probably not a bug, you're probably doing it wrong. Do you have other Collider2D Components attached to the object?

avatar image Positive7 · Jul 24, 2015 at 10:55 PM 2
Share

It works fine here

 GetComponent<PolygonCollider2D> ().enabled = false;


avatar image fuego_see_money · Jul 24, 2015 at 11:30 PM 0
Share

I Agree!

I'm guessing he has two Collider2D components, and is turning it off like so:

  GetComponent<Collider2D> ().enabled = false;

ins$$anonymous$$d of the way you did it. If he only has a PolygonCollider2D component, it will work either way, but if there is more than one and he uses the above way of doing it, it will simply disable the higher component in the hierarchy.

avatar image Joe Long · Jul 25, 2015 at 04:47 AM 0
Share

No I just have one collider on the game object. But i didn't call it like you did. I made a variable

 private PolygonCollider2D coll;

and set it in start to

 coll = GetComponent<PolygonCollider2D>();

 

then in the OnTriggerEnter2D method i put

 coll.enabled = false;

Im still new at this but I thought it might be a bug because i disabled the SpriteRenderer the same way and it worked. Im sure it works if i did it the way you guys said

0 Replies

· Add your reply
  • Sort: 

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

23 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

Related Questions

image not enabling 0 Answers

Enable/Disable Game Object With GUI Button 1 Answer

Enabling loop and disabling loop 1 Answer

Enable/Disable a Static object 1 Answer

error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer 3 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