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
2
Question by oleg9419 · Mar 02, 2014 at 01:24 PM · rotationcolliderscale

Common 2D Collider flip problem

Hello,

I have a 2Dsprite character with an attack animation,and the colliders which are attached to it move with the sprites, that is till I flip my player in -x axis then suddenly during animation my colliders move strangely,they shrink/grow and go in the wrong direction .

dir1 and dir2 file will describe better my situation .

What solution do I have ? More people had same issue but no answer.

FirstQuestion

SecondQuestion

Thank You !

     void flipScene()
     {
         facingRightDirection = !facingRightDirection;
         Vector3 scale = transform.localScale;
         scale.x*=-1;
         transform.localScale= scale;
 
     }
 


dir1.jpg (256.4 kB)
dir2.jpg (276.5 kB)
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 robertbu · Mar 03, 2014 at 01:09 PM 0
Share

If you flipped your sprite by rotating it 180 degrees on the 'y' rather than change the local scale, do you have the same issues?

avatar image oleg9419 · Mar 05, 2014 at 10:53 AM 0
Share

I tried rotating 180 degrees on Y and no luck.

avatar image Kanapesh · Mar 13, 2014 at 08:21 PM 0
Share

Despite the amount of topic on this issue, there's been no answer.. I have the same problem, and it happens whenever you try to flip (negative scale on the X axis)/rotate a gameobject having child with 2D colliders... Nothing seems to work, can somebody help ?

avatar image robertbu · Mar 13, 2014 at 08:34 PM 0
Share

@$$anonymous$$anapesh - I cannot reproduce the problem. I would not be surprised if there are problems using negative x scale. But I wrote a quick test using two objects with polygon colliders and flipped one 180 on the 'Y' (tried flipping both empty game object parent and flipping child with a local offset from parent). Collisions worked fine and I saw no shrinking or growing of the collider. $$anonymous$$aybe you need to open a new question with a simple, reproducible scenario using a 180 rotation on the 'y'.

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Janibasha · Jun 19, 2017 at 01:31 PM

Just change the game object localscale to -1 at a specific condition

transform.localScale = new Vector3(-1, 1, 1);

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

Answer by DricoJD · Mar 02, 2014 at 02:17 PM

I can't seem to re-create this in unity. Colliders should just flip with the sprite aswell, but movement is hard to make colliders move, can you post me your code

Comment
Add comment · Show 5 · 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 oleg9419 · Mar 02, 2014 at 02:44 PM 0
Share

I edited it )

avatar image DricoJD · Mar 02, 2014 at 05:27 PM 0
Share

Try using a collider that covers the whole body ins$$anonymous$$d? Why do you need seperate ones, it wont make the game more appropriete?

avatar image oleg9419 · Mar 02, 2014 at 05:47 PM 0
Share

the problem is why are they behaving abnormally when I flip my sprite . They work as expecting during the animation , but when I flip my sprite they just behave strangely.

avatar image Dblfstr · Mar 06, 2014 at 08:12 PM 0
Share

Are these collider all attached to your sprite or are they children? Is the sprite a child of another gameobject? If you manually rotate it in the scene view, do the colliders rotate as they should?

avatar image Dblfstr · Mar 06, 2014 at 08:20 PM 0
Share

Also, have you looked at

 child.localScale = parent.transform.localScale;



 foreach (Transform child in transform) {
             child.localScale = parent.transform.localScale;
         }
avatar image
0

Answer by Psynbiotik · Jun 22, 2014 at 12:04 AM

This is the closest I've found to an answer:

http://answers.unity3d.com/questions/581430/how-to-properly-flip-2d-character-with-new-unity43.html

Other possible solutions:

  1. Remove rigid body on child object (this worked for me), rigid body is causing this issue.

  2. Disable collider before changing parent, then re-enable when done.

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

Answer by ClearRoseOfWar · Sep 18, 2016 at 01:37 PM

I know some people don't like old threads to be opened.. but this was the top link on google, and also the first one I checked for an answer and couldn't find one here.

Here's what worked for me: Change the sprites scale to -scale. Or even the parent Gameobjects scale

Source: https://feedback.unity3d.com/suggestions/flip-x-and-y-to-polygon-collider-2d

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

26 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

Related Questions

negative scale+rotation+collider 1 Answer

How to change child's rotation whithout affecting it's scale? 1 Answer

how to scale object to fit inside a room 1 Answer

How to rotate a mesh collider? 0 Answers

Animation affects the rotation.. 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