• 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 user5200 · May 31, 2012 at 12:25 AM · rotation2d sprites2d rotationy-axis

2D rotation along the Y-axis produces undesirable results

Hi,

I am trying to make a 2D game in Unity and I am running into this problem of being unable to rotate a 3D object like you would for a 2D object. Here is my problem:

I am using a cube to house a material which contains my texture. Now, if you flip a 2D object 180 degrees on the Y axis, you can get it to face the opposite direction. But, this does not happen in Unity.

Let's say my character is facing right. Upon rotating him 180 degrees on the Y-axis, he should be facing left. But in Unity, the texture is on a 3D cube and on the other side of that cube, he is upside-down. So, when I rotate him 180 degrees, he ends up facing the correct way, but upside-down. No combination of transform.rotate changes seem to make him face the other way and avoid being upside-down.

Is there something I am doing wrong? Perhaps a change in the way the material or the geometry works?

Edit: Here is the solution. Thanks for the help.

Instead of rendering the texture on the cube, I am now using a plane as suggested. And for the shader, I am using Transparant/Cutout/Soft Edge Unlit.

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
0
Best Answer

Answer by whydoidoit · May 31, 2012 at 12:28 AM

I guess you could render him on a plane and use a shader that doesn't do back face culling - or you could just set the X scale to minus whatever it is now. -1 for instance.

Comment
Add comment · Show 3 · 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 user5200 · May 31, 2012 at 07:27 PM 0
Share

Hi, thanks for the comment. Could you elaborate a bit more on shaders? I know very little about graphics implementation and there are a ton of shaders available as well as the ability to create your own.

avatar image whydoidoit · May 31, 2012 at 07:43 PM 0
Share

Yes choosing a shader can be tricky - learning to write them myself at the moment :)

Well most shaders won't draw a triangle if it's normal is pointing away from the camera - this makes it more efficient because that face cannot be seen. So if you just use a plane it only has one side so take a normal shader, and look at it from the other side it won't be drawn. So that is probably why you have yours on a cube - of course that gives you texture wrapping issues.

It's a single line to turn that off in the shader source - normally the shader will have Cull Back and you just need Cull Off. Then a plane with that shader can draw both sides.

I'm guessing for sprites in 2D you are using an unlit transparent shader? Grab the source for it, make a copy, try Cull Off ins$$anonymous$$d of Cull Back wherever it occurs.

Buy I would suggest you just negative scale the X - much easier!

avatar image whydoidoit · May 31, 2012 at 07:46 PM 0
Share

Except that will probably mean no dynamic batching actually - where multiple things using the same texture are done in a single draw call - that has a challenge I believe when any of the objects are scaled.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

how to rotate 2d obj on android 1 Answer

Shooter 2D - Problem with rotation of bullet to face direction (velocity) 2 Answers

Animation in Unity editor prevents rotation in script 1 Answer

Rotate within range 1 Answer

Freeze rotation but needs angular rotate token in Rigidbody 2D 0 Answers


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