I've been searching and experimenting to find a solution to this for a week now, hopefully there's an answer. When I flip my object using localScale.x = -1 the sprite looks fine but the colliders go crazy (multiple GameObjects/colliders for 1 enemy). The colliders also shrink/expand based on rotation (larger as rotation approaches 0, smaller as it approaches 360). My hierarchy is: Enemy [parent] <-- being the one I flip via localScale.x=-1 -body -jaw -left_arm -right_arm -left_leg -right_leg -head I understand it's an issue with non-uniform scaling so I tried changing that to the following and flipping the CHILDREN instead of the parent: Enemy [parent] -jaw -left_arm -right_arm -left_leg -right_leg -head That still didn't work. I also tried: Enemy [parent] -jaw --jaw collider -left_arm --left_arm collider -right_arm --right_arm collider -left_leg --left_leg collider -right_leg --right_leg collider -head --head collider I tried this solution as well but just couldn't figure it out. Any help would be GREATLY appreciated! I've been stuck on this for a week.
That's odd. Could you submit a bug report? Also, rotationg around Y by 180 should work with Sprites as well.
DigiScot: I'm on 4.3.1f1 TomasJ: Rotating on the Y causes weird issues. The dinosaur is made up of several sprites arranged on the Z layer. Rotating Y to 180 makes his left leg in front of the right, etc. You can fix the look by inverting the Z position BUT the colliders don't move with the sprites: I read something the other day by someone on your team, I believe Eric, saying that you should only rotate sprites on the Z axis in a 2D environment. Obviously you can't "flip" a sprite by rotating it on the Z.
Hi Brutang, turns out I was wrong (as you know) with the version, it wasn't that it started working for me, it's because I changed to using the polygon collider, which does rotate correctly. It's not ideal, but it's workable till they fix it, and you can easily delete points to get it down to a similar number or verts, tho I couldn't say how it compares in performance!
The colliders are all Polygon Collider 2Ds; 6 of them. Rotating on the Y or flipping the parent via localScale.x=-1 both cause issues. Flipping via localScale causes non-uniform scaling issues (like shrinking/expanding depending on rotation) and rotating on the Y doesn't adjust the colliders (as shown in the image). I'd love to see how you do it via code or an image as I'm at a loss for how to fix this!
I had collider issues when flipping things but I found I had to... kind of rotate things in a weird way. Pause the game and in the editor play with the rotational values to see if you find what works. I had to do a Quaternion.Euler(0, 90, 270) if the object was on the left and a Quaternion.Euler(0, 270, 90) if it was on the right to get the correct effects, depending on which direction something was instantiated then rotated via Quaternion.LookAt(x) Hopefully something like this helps.
It's the Rigidbody that messes it up, if you don't have one, poly colliders rotates fine that's why it was ok in my tests I did. Really annoying this one!
We reproduced this case and a fix will be available in the next release. Sorry for any inconvenience.
doing a localscale = -1 really messes with the colliders. It would take a working collider and instantly mess up the detection once the scale was reversed, I had to resort to rotation on y
I solved this by enabling and re-enabling the collider every time it's rotation changes using the second method you described. An ugly fix, but it does the job.
Has this been fixed with 4.3.3 ? I still seem to have really weird things going on when rotating child objects of flipped sprites.
i had all these issues on my previous project and i had to abandon it , not only colliders, joints go nuts as well, subscribed to this thread i hope unity fix it soon
Yes I confirm that joints go nuts as well. @TomasJ Can you please give us an ETA on when all of this will get fixed? Thanks
I have the same problem. I'm changing the center of the collider when i rotate my sprite as a workaround, it's working by now but i know that is not the best way to do this. Waiting for the next release...
Has the "next major release" released with the fix yet? I'm not sure what's considered a major release, and my internet is too slow to check myself if it hasn't been fixed. Thanks.
Any action this? It's brutal. My workaround: create a flipped copy of the sprite assets with a whole corresponding hierarchy of associated gameobjects. Instead of flipping the parent transform, I disable one branch and enable the other. Works great - of course - but what a pain.
I am unfortunately having to do the same thing. Well Unity version 5.0 has been announced. Its just a matter of waiting for it to go live. Then apparently everything will be fixed
When it's out, it will show up on the Download page. There's no public schedule of when updates are released. There's a "release notes" link on the Download page as well for seeing what changed in an update.
Well... at least I made my question. Who knows it really exist !? What is release I already read all the release notes.
Looking forward to this fix. I was trying to figure out why rotating a mirrored game object would screw up all of my colliders; it was driving me crazy. Hopefully soon™ means a week or two at most...
One thing that's helped me, is that if you flip the same transform you rotate, it still works, even for colliders of child GameObjects (as long as you don't in turn rotate them separately within the flipped object). Potentially, you can even flip a set of siblings and animate them together, though that's rather more work to animate, since you can't use their parentage and pivot to lock their positions together.
Thanks for the reply. I'm now having a VERY similar problem with parenting a HingeJoint2D or any kind of joint for that matter.
Glad to hear it @Brutang! Unfortunately the fix came too late for me. I had to find workarounds in order to properly flip the tractors in my game Tractor Crew. Anyway, good luck with your game! I can't wait to play it!
It popped up in Unity when I opened the editor saying I was out of date. Should be the latest version here.
Not that I see; I think I read something about the f2 f3 etc updates are patches, so they don't treat them as full version releases. Could be wrong, been cramming a lot into my brain today
I rotate my player on Y... Works fine, the scale = -1 and 1 really messes unitys colliders up i found, but rotation worked fine, it rotated the colliders with the sprite....
Hi. I confirm colliders don't flip with sprites. I send attachments. When I flip sprite, collider stays in the same position. Unity version 2020.3.5f1
Yes, they're not supposed to. Colliders can be flipped with Transform scale which is what the thread is about. The whole point of the flip sprite feature is to avoid flipping everything else that relies on the Transform, including children. "Flipping" colliders means recreating them from scratch.