Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 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 Spidermanisgay · Mar 01 at 10:54 AM · rotationquaternionlerp

Lerp rotation 90 degrees on jump

I simply wish to rotate the player character 90 degrees forward (-90 on the z) with every jump. The player character is a square, I'm trying to emulate the geometry dash style where it lands on the front facing face every jump after a little rotation. Transform.rotation isn't working at all it seems. I have tried euler angles, which was the closest solution, but it wouldn't always rotate exactly 90 degrees. I've learned I cannot read euler angles consistently, but neither quaternions nor simply influencing the rotation seems to be working. Here is the code. It seems like it should be a super simple thing to achieve, what am I doing wrong?? Everything commented out are solutions I have attempted to no avail. The current rotation variable I have shifted between vector 3 and a quaternion depending on what I've been trying. I'm probably just a fool, but please help me solve this. The last ground check incrementing if statement changes the ground check transform to the next face to accurately see if the square is grounded.

 void Update()
         {
             currentMoveSpeed += moveSpeedIncreaseModifier;
             grounded = Physics2D.OverlapCircle(groundedCheck[groundedCheckNumber].position, groundRadius, groundLayer);
             if (grounded)
             {
                 jumping = false;
             }
             if (jumping)
             {
                 transform.rotation = Quaternion.RotateTowards(currentRotation, new Quaternion(transform.rotation.x,transform.rotation.y,currentRotation.z -90f,1) , Time.deltaTime * rotationSpeed);
                 //transform.eulerAngles = Vector3.Lerp(transform.eulerAngles,currentRotation, Time.deltaTime * rotationSpeed);
                 //transform.rotation = Quaternion.Lerp(currentRotation, new Quaternion(transform.rotation.x, transform.rotation.y, currentRotation.z - 90f, 1), Time.deltaTime * rotationSpeed);
             }
             myRB.velocity = new Vector2(currentMoveSpeed, myRB.velocity.y);
             if(Input.GetKeyDown(KeyCode.Space) && grounded)
             {
                 currentRotation = transform.rotation;
                 jumping = true;
                 myRB.velocity = new Vector2 (myRB.velocity.x, jumpForce);
                 //transform.rotation = Quaternion.Lerp(transform.rotation, new Quaternion(transform.rotation.x, transform.rotation.y, transform.rotation.z - 90f, 1), Time.deltaTime * rotationSpeed);
                 //transform.RotateAround(transform.position, transform.up, new Vector3(0f,0f,90f));
                 //Vector3 rotate90 = new Vector3(transform.rotation.x, transform.rotation.y, transform.rotation.z + 90f);
                 //transform.eulerAngles = Vector3.Lerp(transform.rotation.eulerAngles destination,Time.deltaTime);
                 if (groundedCheckNumber == 3)
                 {
                     groundedCheckNumber = 0;
                 } else
                 {
                     groundedCheckNumber++;
                 }
             }
         }
 
 
 

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

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

180 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image

Related Questions

How to ROTATE an object without slowing the ends (lerp) 3 Answers

How can I use lerp to rotate an object multiple times? 2 Answers

Rotate children (Cards) on a panel (maybe using lerp, or another method?) 1 Answer

How would I smooth out a Quaternion? 2 Answers

How to rotate towards the mouse on one axis while snapping 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