Hi All,
I am trying to do Lerp rotation animation in x axis by getting values from InputField. During runtime, Everytime I type a value in InputField and press Enter, I call a function to update the latest Value to the class.
The GameObject should rotate and stop as per the value. Here’s how I coded. Not works as expected.
Could you Help me:
public class getInputFocus : MonoBehaviour {
public GameObject rotPlate;
private float inputValue;
private Vector3 rotateTo;
private float rotSpeed = 2.0f;
void Update () {
if (rotPlate.transform.eulerAngles.x != rotateTo.x) {
rotPlate.transform.eulerAngles = Vector3.Lerp (rotPlate.transform.eulerAngles, rotateTo, Time.deltaTime*rotSpeed);
}
}
public void getInput(string UserInput) // From InputField
{
Debug.Log (UserInput);
inputValue = float.Parse (UserInput);
//User values should be within 0 to 100
if((inputValue <= 100) && (inputValue >= 0))
{
//Convert values into Angle Because roation angle should be 0-90
float newValue = (inputValue / 100) * 90;
rotateTo.x = newValue;
}
}
}