Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Apr 26, 2016 at 10:06 AM by meat5000 for the following reason:

Consult the manual and hit the tutorials or search pre-existing material on Unity Answers.

avatar image
1
Question by SebastianScaini · Apr 26, 2016 at 04:23 AM · 2dspriterotate

[2D] How do you rotate a 2D sprite left and right with C#?

I've only been able to rotate the sprite along it's Y-axis with Vector3 and Vector2, which has not been working. It's been a long time since I last worked with Unity so I'm a little (lot) rusty.

Comment
Comments Locked · Show 2
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 Cherno · Apr 26, 2016 at 09:06 AM 0
Share

If your view is true top-down, then negative z is your sprite's upwards vector. That means that such a sprite rotates left and right with it's z axis.

If you game uses a sideview, then the y axis is your sprite's upwards vector.

You can use transform.eulerAngles to change any axis xyz values. If you want to flip sprites, you just invert the x scale of the sprite.

avatar image meat5000 ♦ · Apr 26, 2016 at 10:06 AM 0
Share

Please read the $$anonymous$$anual for basics. It is updated, you know.

2 Replies

  • Sort: 
avatar image
2
Best Answer

Answer by Viaticum · Apr 26, 2016 at 09:06 AM

@SebastianScaini As I understand and have used, 2D rotation happens along the Z axis by default, be it through the animator or code. Try passing Transform.Rotate a Vector3 with your desired angle (perhaps multiplied by Time.deltaTime) in the Z axis.

Comment
Comments Locked · 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 mohammad-alavi-74 · Apr 26, 2016 at 07:56 AM

you may want to look at this documentation:

http://docs.unity3d.com/ScriptReference/Transform.Rotate.html

Comment
Comments Locked · 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

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Finding the centre of two touches 2 Answers

Quaternion Rotate Towards Y Value 1 Answer

Sprite "face" second sprite only on Z axis 2 Answers

2D lock x,y rotation to look at target 2 Answers

Mirroring sprite around arbitrary axis causes collision issues 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