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 Francissaccordi · Apr 24, 2014 at 07:16 AM · rotationjoysticksmoothhowstandard-assets

Smooth rotate use joystick

i have a game object that i want to rotate when player move the joystick to left and right. i use single joystick from standard asset mobile . i use

 void Update(){
 
 xposisi = GameObject.Find("Single Joystick").GetComponent<Joystick>().position.x ;
 
 
 transform.eulerAngles = new Vector3(0,0, xposisi * 10); ;
 }

but that rotate doesn't smooth. i need more smooth rotate. what should i do? thankyou for all respons and im sorry for my bad english

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

1 Reply

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

Answer by teslatron · Apr 24, 2014 at 09:25 AM

Try like this:

 Quaternion eulerRot = Quaternion.Euler(0.0f, 0.0f, xposisi);
 transform.rotation  = Quaternion.Slerp(transform.rotation, eulerRot, Time.deltaTime * 10);
Comment
Add comment · Show 6 · 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
avatar image Francissaccordi · Apr 25, 2014 at 03:21 AM 0
Share

hmmm i have try this but my object doesn't rotate. what do you think?

avatar image Francissaccordi · Apr 25, 2014 at 03:40 AM 0
Share

wooow awesome. its work!! my object didn't rotate because that value is to small. i multiple xposisi like this. Quaternion eulerRot = Quaternion.Euler(0.0f, 0.0f, xposisi*50); and its rotate smoothly. Greaat answer!! thanks a lot!! wew, i have spend 3 days for fix it. hehe

avatar image Francissaccordi · Apr 25, 2014 at 04:06 AM 0
Share

if u are not busy, can u explain how does it work?, i only understand for a bit

avatar image teslatron · Apr 25, 2014 at 08:53 AM 0
Share

Lerp and Slerp functions in unity is widely used for smoothing. Lerp is used for linear interpolated situations, Slerp is used for spherically interpolated (usually rotations).

For your situation, if you set your rotation directly, your rotation will be sharp and crude. (sometimes that is what we want) The key is we don't set the rotation directly, but we set to our target rotation by time. The longer it takes, the better its smoothed.

You better check this tutorial out: http://unity3d.com/learn/tutorials/modules/beginner/scripting/lerp

Also these: https://docs.unity3d.com/Documentation/ScriptReference/Vector3.Lerp.html https://docs.unity3d.com/Documentation/ScriptReference/Vector3.Slerp.html http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Slerp.html

avatar image Francissaccordi · Apr 28, 2014 at 02:04 AM 0
Share

aaahhh i see. thankyou bro!

Show more comments

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

How to smoothly rotate object in direction of analog joystick? 1 Answer

Choppy rotation of character around y-axis 1 Answer

Rotation - Simple Question 0 Answers

Rotate smoothly an object when key is up 0 Answers

Smooth reset rotation problem 1 Answer


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