Question by
Lichev · Dec 08, 2017 at 02:50 PM ·
rotationspeedrotationsspeed issues
Space.Self smooth rotating menu around hand. How can I control the speed of the rotation?!?!?
Here is the script:
using UnityEngine;
public class Lerp : MonoBehaviour
{
[Range(0, 360)]
public float angle = 120;//Specify Angle For Rotation
float tempAngle;//Temporary Angle Measurement Variable
bool horizontalFlag;//Check For Horizontal Roation
bool isRotating;//Check Whether Currently Object is Rotating Or Not.
int Direction;//Direction Of Rotation
//Called For Initialization
void Start()
{
horizontalFlag = isRotating = false;
}
//Method For Horizontal Input
void CheckForHorizontalInput()
{
if (Input.GetAxis("Horizontal") != 0 && !isRotating)
{
isRotating = true;
Direction = (Input.GetAxis("Horizontal") < 0 ? - 1 : 1);
horizontalFlag = true;
tempAngle = 0;
}
}
//Method For horizontal Rotation
void HorizontalRotation()
{
transform.Rotate(Vector3.back * angle * Time.fixedDeltaTime * Direction, Space.Self);
tempAngle += angle * Time.fixedDeltaTime;
if (tempAngle >= angle)
{
tempAngle = 0;
isRotating = false;
horizontalFlag = false;
}
}
void Update()
{
CheckForHorizontalInput();
if (horizontalFlag)
HorizontalRotation();
}
}
Comment
Your answer
Follow this Question
Related Questions
Rotating an object with the mouse and retrieving data 0 Answers
Minor issue with a VR head tracking script to control the camera? 1 Answer
C# Min/Max Rotation based on Float? 1 Answer
trying to get local forward and side to side values 0 Answers
how can I make player rotate towards mouse and measure the speed of that rotation?, 0 Answers