Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by vahag1313 · Aug 11, 2016 at 08:46 AM · physicscollidersscaleflipping

Box colliders and negative scales

I'm trying to "flip" objects with a negative X scale. In 5.3.4 this works well. In 5.4 , box colliders seem to be actually working correctly, but somewhat ironically we get spammed with this warning for every instance of a flipped collider:

BoxColliders does not support negative scale or size. The effective box size has been forced positive and is likely to give unexpected collision geometry. If you absolutely need to use negative scaling you can use the convex MeshCollider.

Now I can imagine that certain configurations with negative scales do act badly with box colliders, but in our case of a simple (-k, k, k) type of scale they seem to work well enough for our purposes. Are there lurking issues even with this type of setup? Is there a way for us to disable this warning?

Flipping objects by applying a -1 scale to one axis is something that a lot of people want to do for certain types of games, so it would be handy if this was supported as cleanly as possible.

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

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by money4honey · Nov 04, 2016 at 08:44 PM

BoxColliders does not support negative scale or size. The effective box size has been forced positive and is likely to give unexpected collision geometry. If you absolutely need to use negative scaling you can use the convex MeshCollider

so, if you want use negative scale, you must replace box collider with convex MeshCollider.
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 trialforce · Nov 04, 2016 at 09:11 PM 0
Share

I don't have a mesh, it's a 2d game.

Can I use $$anonymous$$eshCollider with default Unity box model?

This seem wrong to me.

But it' always worked, why break compatibilty now?

avatar image money4honey trialforce · Nov 04, 2016 at 09:20 PM 0
Share

I don't know why unity devs break this compability for now, maybe they do this due performance optimization. if you create 2D game, you can separate colliders and sprite renderer in different objects (which have same parent), and set negative scale only for sprite renderer. it works for me

avatar image
1

Answer by xTyler73 · Jun 19, 2017 at 09:40 PM

A way to fix this is to actually set the scale of the object with the box collider that is causing the warning to be negative. The negative of this object combined with the parent object that is negative cancels them out to be positive.

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 MaciekXB · Jun 09, 2021 at 08:48 PM 0
Share

Thank you! I had this in an asset from the store which uses scale (-1,1,1) for mirrored child 3D game objects. Simply changing the scale x to -1 in the child objects with the collider was a simple workaround!

avatar image
1

Answer by omarmoh-om · Aug 15, 2017 at 09:12 PM

I had the same Issue and it isn't that difficult to fix too. Somewhere in your project where you are re-scaling or resizing a GameObject (With a box collider attached to it) and or a Box collider, and the variables that calculates that getting subtracted. Subtracting a positive from negative you now have the chance to make the size or scale negative; which mathematically wrong, like having the distance to be negative. for example, if you are doing something like this with a variable named foo:

 foo.transform.localScale = new Vector3(foo.transform.localScale.x, foo.transform.localScale.y, foo.transform.localScale.z-1f);

this will generate the error because of the chance of the z-axis scale to be 0.5f, this causes the scale to be -0.5 which is now allowed or possible. It will cause weird collisions and detection from unity side if you are going with this. To fix this problem and avoid having the warning or negative values you must use:-

 float newZScale = Mathf.Abs(foo.transform.localScale.z - 1f); 
 foo.transform.localScale = new Vector3(foo.transform.localScale.x, foo.transform.localScale.y, newZScale); 

Mathf.Abs, take the whatever the value is and make it positive This way even if the values generated a negative value it will still get accepted and transformed into positive ones, and it will get rid of this warning in Unity 5.4.2f2.

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 koby234 · Feb 10, 2020 at 05:20 PM 0
Share

Doesn't this only scale the body and children? The question talks about "flipping", can this be achieved?

avatar image
0

Answer by eirikamb · Aug 11, 2016 at 09:23 AM

The way to work around the error is to hae all positive but change the centre... It dont seem like you want an answer but just a place to complain, but this is a way to work around it

Comment
Add comment · Show 7 · 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 vahag1313 · Aug 11, 2016 at 09:29 AM 0
Share

What? Please explain with more details

avatar image eirikamb vahag1313 · Aug 11, 2016 at 09:33 AM 0
Share

In the box collider Settings... Right above size is center, that is how you change the position of the collider... If you change it negative to half of the size, it should be exactly like havig for example -1 in size

avatar image vahag1313 eirikamb · Aug 11, 2016 at 09:36 AM 0
Share

I think you've misunderstood my question, I'm assigning negative scale not exactly to boxCollider component but to transform component's scale

Show more comments
avatar image eirikamb vahag1313 · Aug 11, 2016 at 09:36 AM 0
Share

but you didnt actually have a question in your post, you didnt ask for a way to fix it, just complain of how it is not working like it used to before

avatar image vahag1313 eirikamb · Aug 11, 2016 at 10:02 AM 0
Share

We used to flip characters with applying negative scale, and that wasn't a problem for years and now suddenly Unity shows some warnings. And I don't know whether it's my fault or Unity's bug or something else.

Show more comments
avatar image
0

Answer by trialforce · Sep 14, 2016 at 12:35 PM

I recently migrate to unity 5.4 I have the same issue. To me, migrate to newer version is not a good think. I always have issues. I flip the character with negative scale. What other way I could do this if are 3d or 2d. I wil try to rotate, ou flip 2d sprite. Thanks!

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
  • 1
  • 2
  • ›

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

87 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

Related Questions

Car flipping and losing wheels on start 0 Answers

Changing Scale Effect Physics? 1 Answer

Player Is able to rotate through walls. 2 Answers

Stop Objects from stacking on top of each other? 1 Answer

How to animate collider along with object for 2D game? 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