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 /
  • Help Room /
avatar image
0
Question by blingximus · Mar 07, 2016 at 03:36 PM · transform.rotationtransform.

Rotate 3d character in 2d space

I been struggling with this issue for 3 days now.

Searched the answers and still nothing concrete.

All I want is for my 3d character to look left and right.

But the rotation inputs get messed up somehow and it's like I cant edit the rotation values to just go back and forth between two Y values. below is my code.

     public float xRotation = 0f;
     public float yRotation = 90.0f;
     public float yrRotation = -90.0f;
     public float zRotation = 0f;
 
     bool facingRight = true;
 
     void FixedUpdate()
     {
       float move = Input.GetAxis("Horizontal");
     
       if (move > 0 && !facingRight)
         {
            
             facingRight = !facingRight;
             transform.localEulerAngles = new Vector3(xRotation, yrRotation, zRotation);
 
             Debug.Log("Transform: " + transform.localEulerAngles.ToString());
         }
         else if (move < 0 && facingRight)
         {
             
             facingRight = !facingRight;
             transform.localEulerAngles = new Vector3(xRotation, yRotation, zRotation);
 
             Debug.Log("Transform: "+transform.localEulerAngles.ToString());
 
         }
 
 }


LOGS:

When I look left: Transform: (0.0, 180.0, 0.0)

When I look right: Transform: (0.0, 358.0, 0.0)

How can make my character just rotate a fixed amount back and forth every time?

Comment
Add comment · Show 1
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 blingximus · Mar 10, 2016 at 04:01 PM 0
Share

No one knows how to solve this?

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Rotation snapping to 180 degrees with transform.rotation 1 Answer

Multiplayer THIRD PERSON CHARACTER SPINE ROTATION PROBLEM 1 Answer

Cannon rotation clamping 0 Answers

How to attatch two objects at their children, with child rotation 0 Answers

Replicate local movement between objects 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