- Home /
The best way for working with rotation in 2d game
I'm making a 2d game. I have an object that can face left or right. I want to flip the object upside-down. At first, I try to multiply the transform.up with -1 but doing so will always make the transform.right reset back to normal (meaning the object can't face left). I already know that Unity save an object's rotation by quaternion and change directly the up vector or the Euler angles won't make the object rotates correctly because there isn't enough information in a vector. What is the best way to tackle this problem? Most of the other posts that I saw focus mainly on 3d games which I don't know will be any different from 2d games. In the past, I mainly changed the eulerAngles property or the up/right vector when working with rotation. In doing so, I realized that it had a lot of problems and wanted to change the way I used it.
Answer by Anonymous620 · Jul 11, 2021 at 11:11 AM
You can use unity's flip option Edit: Sorry, i didn't read it properly, you can use localscale on the y axis.
But I want to actually flip the transform so that the rotation and up vector is changed. Maybe I wasn't cleared but I want to know how to change rotation in 2d. Are there any functions to do so, I saw transform.Rotate() but it only adds the rotation rather than sets it. Converting Euler to quaternion by some helper functions isn't a good way either, because there are multiple euler angles, and change one axis usually resolve in an entirely different rotation.
Sorry this is a bit late, i've been busy with school but if you still need help can you describe what kind of rotation you want to occur.
Thanks, but I solved it. In the end, I just changed the whole rotation using Quaternion.Euler