smooth rotation unity

Vector3 targetRotation = path[i].transform.position - transform.position;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(targetRotation), 4f * Time.deltaTime);
//LookRotation points the positive 'Z' side of an object in a specified direction
//FromToRotation creates a rotation that from one direction to another direction

3.9
10
Yuzu 90 points

                                     float targetAngle = 90;
 float turnSpeed = 5;
 transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.Euler (0, 0, targetAngle), turnSpeed * Time.deltaTime);

3.9 (10 Votes)
0
4.29
7

                                     float targetAngle = 90; float turnSpeed = 5; transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.Euler (0, 0, targetAngle), turnSpeed * Time.deltaTime);

4.29 (7 Votes)
0
3.8
5

                                     private float desiredRot;     public float rotSpeed = 250;     public float damping = 10;      private void OnEnable() {         desiredRot = transform.eulerAngles.z;     }      private void Update() {         if (Input.GetMouseButton(0)) {              if (Input.mousePosition.x > Screen.width / 2) desiredRot -= rotSpeed * Time.deltaTime;              else desiredRot += rotSpeed * Time.deltaTime;          }          var desiredRotQ = Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, desiredRot);         transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotQ, Time.deltaTime * damping);     }

3.8 (5 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
unity gameobject rotation smooth unity gameobject smooth rotation unity smooth gameobject rotation unity smooth rotation to angle unity smooth 2d rotation unity smoothly rotate object unity smooth rotate towards object 2d how to set rotation smoothly unity transform.rotate smooth unity how to make a rotation smooth in unity unity3d smooth rotation unity smooth rotating rotate around unity smooth how to rotate gameobject smoothly unity change rotationm smoothly unity unity 2d rotations too smooth unity 2d rotations to smooth how to rotate smoothly unity smooth rotate unity rotate object unity smoothly smoothly rotate unity smoothly rotation unity 2d smooth rotation unity unity smooth rotation code make 2d game smooth in unity unity 2d smooth rotation unity rotate object smoothly smoothdamp unity 2d how to smoothly rotate objects in unity make rotation smooth unity how to smooth rotate an object in unity smoothly go to a rotate unity unity smooth animation rotation unity smooth look rotation unity smooth rotation 2d rotate an object smoothly unity how to smooth rotation in unity unity rotate smoothly smoothly rotate in a position unity Unity rotate an object transform.rotate is slowly unity unity smoothly rotate unity transform rotate around local transform.rotation smooth unity quaternion smooth rotation smooth rotaion unity unity rotate smoothly in time smooth transform.rotate unity unity rotate without update smoothly change rotation unity unity rotate aroud and stop unity right mouse rotate unity transform rotate smooth unity how to rotate by scale rotate gun unity rotate strange moving position unity smooth rotate through script unity slowly rotate object unity smoothly rotate object unity how to smooth transform.rotate smooth transform.rotate smooth rotation unity unity change rotation smoothly unity rotate object smooth unity smooth rotation unity smooth rotate rotate object smoothly unity rotate slowly unity rotate smooth unity
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source