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 /
avatar image
0
Question by stiwdiopaned · Nov 22, 2016 at 06:55 PM · rotationcollider2dboxcollider2dpolygon collider 2d

Rotating Box Collider 2D independent of its gameObject [v4.7.2f1]

I have a sprite with a diamond shape (1:1 proportions), and I want a 2D box collider to match its outline. Problem is, I can't find a way to simply rotate the box collider independently, like I can adjust its size and center.

I know I could solve it by making a gameobject as a child of the sprite object and rotating that, but that doesn't seem very elegant. Is there not a more streamlined way that would let me rotate the box collider? Seems weird that I can adjust its size and center but not rotation. If that's really not possible, does anyone know why that might be, as in why did the Unity devs make that choice? Seems a weird omission. I'm in Unity 4.7.2f1 (using this version because I'm following an Udemy course), does this get changed in newer versions of Unity?

Also, I have tried using a polygon collider, but my sprite has some alpha sections in it, so weird little islands get created in the collider which mess with collisions and lead to things getting trapped.

With box collider alt text

With polygon collider alt text

Thank you for any insight, :).

screenshot-2016-11-22-134710.png (80.7 kB)
screenshot-2016-11-22-134651.png (86.9 kB)
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
3

Answer by hexagonius · Nov 22, 2016 at 09:06 PM

I can't really say why rotating a collider component is not implemented, but I it's definitely easier to either just create the child gameobject rotated, OR, create a polygon collider manually. from the looks of it you generated it, but you could better manually frame your sprite with the edit option on the collider component

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 tanoshimi · Nov 22, 2016 at 09:16 PM 1
Share

The only explanation I can suggest is that "box" does normally imply an axis-aligned rectangular shape. If you could rotate it, it would become an arbitrary quadrilateral collider and, if you want one of those you can use the polygon collider as suggested.

avatar image Nicola-Patti · May 03, 2017 at 11:49 PM 0
Share

you are a genius! it worked perfect for me, i created a child gameobject with a box collider and transformed the gameobject. This is the result :D alt text

2dboxcollidertransformed.jpg (17.4 kB)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Change polygon collider depending on the animation 0 Answers

Turning off trigger with multiple box colliders? 0 Answers

How to move BoxCollider2D 1 Answer

How to create a 3d polygon collider? 3 Answers

Add PolygonCollider2D from code and ignore sprite mesh 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