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 Voxx · Jun 11, 2012 at 12:08 PM · c#rotationtransformsmoothslerp

Smooth rotation problem

I saw many expanaitons about smooth rotation but i can't figure out how it works in my project. I want to rotate a wheel by a constant angle from the current position on the X axis if a button is pushed.

This is the current state:

 using UnityEngine;

using System.Collections;

public class rotor1 : MonoBehaviour {

 public float rotate_angle = 360f/26f;
 public int turn_on = 1;
 public int i = 0;
 public int j = 0;

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     
     if((Input.GetButtonDown("A") || Input.GetButtonDown("S") || Input.GetButtonDown("B") || Input.GetButtonDown("C") || Input.GetButtonDown("D") || Input.GetButtonDown("E3") || Input.GetButtonDown("F") || Input.GetButtonDown("G") || Input.GetButtonDown("H") || Input.GetButtonDown("I8") || Input.GetButtonDown("J") || Input.GetButtonDown("K") || Input.GetButtonDown("L") || Input.GetButtonDown("M") || Input.GetButtonDown("N") || Input.GetButtonDown("O9") || Input.GetButtonDown("P0") || Input.GetButtonDown("Q1") || Input.GetButtonDown("R4") || Input.GetButtonDown("T5") || Input.GetButtonDown("U7") || Input.GetButtonDown("V") || Input.GetButtonDown("W2") || Input.GetButtonDown("X") || Input.GetButtonDown("Y") || Input.GetButtonDown("Z6")))
     {    
         i++;
         if (i % turn_on == 0 && i != 1){
         
         transform.Rotate(rotate_angle, 0,  0);
         j++;
         Debug.Log(j + "/26 fordulat");
         if ( j % 26 == 0){
             Debug.Log("Teljes fordulat");
         }
         //light.intensity = 3;
         }
     }
 
 }

}

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
0

Answer by Ray-Pendergraph · Jun 11, 2012 at 12:21 PM

¥our angle is too large for a multi frame operation. You either need to lerp from one rotation to another or decrease the rotate_angle greatly. Update gets called many times a second. Your code is if you want to rotate a known angle all at one time. This rotates a wheel very slowly around the Y axis:

 void Update () {
     transform.Rotate(0,Time.deltaTime * 5,0);
 }

Your code sets rotate_angle to roughly 14 degrees so multiply that times 30 frames a second and that's about 415 degrees of rotation a second. Time.deltaTime * 5 is less than 1.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unit rotation fails consistently on all slerp rotations after the first? 0 Answers

HoloLens - Smooth Rotation doesn't work 0 Answers

Flip over an object (smooth transition) 3 Answers

Quaternion Rotation Smooth 1 Answer

accessing an array of rigidbodies at once? c# 2 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