Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by ArkVoid · Mar 04, 2014 at 02:37 PM · horizontal movement

Tilt player on movement

Okay so I'm making a simple 2d game and I want my player to tilt a bit to the direction he is moving to. my problem is that the player doesn't tilt back to 0 (angles- the origin) after he moved.

 void updateROT()
     {
         if (Input.GetAxisRaw ("Horizontal") > 0 || Input.GetAxisRaw ("Horizontal") < 0)
         {
             current = Vector3.Lerp (current, upV3, Time.deltaTime * rotationSpeed);
         } 
         else 
         {
             current = Vector3.Lerp (current, origin, Time.deltaTime * rotationSpeed);
         }
     }

*The if opposite I know you could do != 0 but i just changed temporary

When I run the game and start moving the player he tilts normally but when I stop him he stays tillted...

Thanks in advanced!

Comment
Add comment · 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 ArkVoid · Mar 06, 2014 at 07:00 AM 0
Share

And also do I need to fix the angle of the rigidbody or not?

avatar image highpockets · Mar 06, 2014 at 07:21 AM 0
Share

It's hard to tell whats happening without the rest of your code. Are current, upV3 and origin euler angles??

Assu$$anonymous$$g that they are, try this ins$$anonymous$$d:

 transform.eulerAngles = Vector3.Lerp( current, upV3, Time.deltaTime * rotationSpeed);

This being said, I have no idea what you are doing with current, origin and upV3 outside of this little code snippet that you have provided.

Providing more of your code will help to better understand your issue

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by haim96 · Mar 06, 2014 at 07:49 AM

i can't help you with code at this point of time but maybe i can direct you to an answer. when i had problem with my player rotation i looked for answer and found that the best way to tilt is to parent your player to controller object (some empty gameobjet) and while the empty parent control the X and Y movement you free to tilt the child object (your player) without effecting his movement direction. the tilt it self can be done by starting coroutine that match the tilt direction to the parent direction and velocity. hope it help you some how...

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

22 People are following this question.

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

Related Questions

Glitchy collisions 0 Answers

How to make a circular 2D map. 2 Answers

Horizontal Input 1 Answer

How do I automatically go diagonally when hitting a diagonal? 1 Answer

Horizontal axis to touch input 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