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;
}
}
}
}