• 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 Jeeva3m · Nov 27, 2015 at 10:05 AM · animationinputfieldrotation axis

How to do Lerp Rotation, by getting values from InputField?

Hi Friends,

I am trying to get the rotation angle from user via InputField, and accordingly rotate the gameobject slowly.

How to lerp from previous state and the current angle whenever we type values in InputField and Press Enter?? I am calling the lerp function every time from End Edit String.

Thanks Jeeva

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 Jeeva3m · Nov 30, 2015 at 03:30 PM 0
Share

Hi, Waiting for some help

Little $$anonymous$$ore Explanation:

I am trying to do Lerp rotation animation in x axis by getting values from InputField. During runtime, Everytime I type a value in InputField and press Enter, I call a function to update the latest Value to the class. The GameObject should rotate and stop as per the value. Here's how I coded. Not works as expected. Could you Help me:

public class getInputFocus : $$anonymous$$onoBehaviour { public GameObject rotPlate; private float inputValue; private Vector3 rotateTo; private float rotSpeed = 2.0f;

 void Update () {
 
     if (rotPlate.transform.eulerAngles.x != rotateTo.x) {
             rotPlate.transform.eulerAngles = Vector3.Lerp (rotPlate.transform.eulerAngles, rotateTo, Time.deltaTime*rotSpeed);
     } 
 }

 public void getInput(string UserInput) // From InputField
 {
     Debug.Log (UserInput);

     inputValue = float.Parse (UserInput);
     //User values should be within 0 to 100
     if((inputValue <= 100) && (inputValue >= 0))
     {
         //Convert values into Angle Because roation angle should be 0-90
         float newValue = (inputValue / 100) * 90; 
         rotateTo.x = newValue;
     }
 }

}

1 Reply

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

Answer by Jeeva3m · Dec 09, 2015 at 06:02 AM

Hi friends, For this problem, I got the perfect answer from the following thread. we need to use Quaternion.Lerp instead of Euler angles to work perfectly at least in this case.

http://answers.unity3d.com/questions/1105467/problem-in-lerp-rotaion-based-on-inputfield-value.html#answer-1109520

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to stop Mecanim form doing a weird Rotation? 1 Answer

GameObject rotation not working 2 Answers

FPS Character look up 1 Answer

Animated Sprite Rotating Around It's Own Axis Instead Of Parent's Using Script. Details Provided. 0 Answers

Can the animation editor create local rotational data? 3 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