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 rafi1309 · Aug 27, 2015 at 07:54 PM · lerprotate objectquaternion.slerp

How to rotate smoothly

Hey, I started Unity a week ago and until now some search here help me but now I'm kinda stuck. The thing is, I want to rotate an arm smoothly with the mouse Y coordinate so I try to use Quaternion.Slerp and all but the arm still teleport from one position to another if, for example, I let go the mouse button and I click on another Y position. Here is my code:

     void Start () {
         ArmStart = transform.rotation;
     }
     void Update(){
         Vector3 mousePos = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 10);
         Vector3 lookPos = Camera.main.ScreenToWorldPoint (mousePos);
         Vector3 BoundPos = Camera.main.ScreenToViewportPoint (mousePos)*100;
 
         if (Input.GetMouseButton(0)&& BoundPos.x < 96 && BoundPos.x > 65 && BoundPos.y < 90 && BoundPos.y > 55) {
             float speed=50f;
             float angle = ((Mathf.Atan2 (lookPos.z, -lookPos.y) * Mathf.Rad2Deg) - 130) * 2.8f;
             Quaternion ArmGoal = Quaternion.AngleAxis (angle, Vector3.forward);
             transform.rotation= Quaternion.Slerp(ArmStart,ArmGoal,speed*Time.deltaTime);
             ArmGoal=ArmStart;
         }
     }

Don't mind the condition for the if, it's cause I want that we can control the arm inside precise bound. If you have any idea why it don't work or if you have a better idea... or if you just want to laugh at a damn noob answer please.

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 rafi1309 · Aug 27, 2015 at 07:55 PM 0
Share

Yeah, also, sorry for the broken English inside and outside my code.

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

26 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

Related Questions

RotateAround an object with clamped limits 0 Answers

What is lerpSpeed? 0 Answers

Problem in LERP Rotaion Based on InputField Value 2 Answers

How to slowly render a line through multiple points in a list? 0 Answers

How to shoot to a vector2 of a gameObject's Position?? 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