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 nerds89 · Dec 03, 2016 at 09:46 AM · charactercontrollercharacter movementflip

Can't flip the character other way around

worked it out But when i changed my animation a bit And then out of the blue something happened the character was not flipping when moved backwards i dont know why but the code is alright according to me. help plz INFO: it should flip the chaacter th main player along the x axis i.e. when moved left side and then when moved right it should flip it again. it was working but it is not now i dont know what triggered the change but i really just changed the walking animation a bit plz help ..

         if (Input.GetKeyDown(KeyCode.P))
         {
             if (paused)
                 resume();
             else
                 pause();
         }

         float x = Input.GetAxisRaw("Horizontal");

         if (x == 1)
         {
             rb.velocity = new Vector2(moveSpeed, rb.velocity.y);
             anim.SetBool("walk", true);

             if (facing == -1)
             {
                 transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
                 anim.transform.Rotate(new Vector3(0, 180, 0));
             }

             facing = 1;
         }
         else if (x != -1)
         {
             anim.SetBool("walk", false);
             rb.velocity = new Vector2(0, rb.velocity.y);
         }

         if (x == -1)
         {
             if (facing == 1)
             {
                 Debug.Log("flipped");
                 anim.transform.Rotate(new Vector3(0, 0, 70));
                 facing = -1;
                 transform.localScale = new Vector3(transform.localScale.x * 3, transform.localScale.y, transform.localScale.z);
             }

             rb.velocity = new Vector2(-moveSpeed, rb.velocity.y); anim.SetBool("walk", true);
         }
Comment
Add comment · Show 4
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 tanoshimi · Dec 03, 2016 at 09:48 AM 0
Share

"Not working" is a fairly useless way of describing a problem. What do you expect it to do? What does it actually do? What did you change since the last time it was working? What error messages do you receive?

avatar image nerds89 · Dec 06, 2016 at 10:25 AM 0
Share

pl help still waiting.. @tanoshimi

avatar image tanoshimi nerds89 · Dec 06, 2016 at 10:32 AM 0
Share

You appear to be rotating by 180 degrees about the y axis and inverting the local x scale - I would have thought that either one of these would achieve what you're after, but doing both cancel each other out:

              transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
              anim.transform.Rotate(new Vector3(0, 180, 0));
avatar image nerds89 · Dec 06, 2016 at 12:38 PM 0
Share

@tanoshimi actually i am rotating the character by multiplying the scale by -1 and then rotating the animation of the player by y axis so that the animation matches the player..

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by nerds89 · Dec 19, 2016 at 02:21 AM

@tanoshimi i found the answer. the crouch animation was interfering in a sense the scale value was stored in the animation so the flipping of the character was not possible now its functioning properly

Comment
Add comment · 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

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

Issues with making a climbing script compatible with CharacterController 0 Answers

Character moves opposite ways.,My character moves perfectly to every direction except -z. 0 Answers

How can I modify this to allow jumping with space? 0 Answers

Character wont shoot to the left in Unity 2D 0 Answers

Why is my character flying off screen? 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