How to convert User Values into degree(Angle)??
Hi Friends,
I am trying to get values from a InputField and based on that do the rotation. But here the challenge is: the user will type values from 0 to 100 and the 3D gameobject should rotate 0 to 90 degrees only, means if the user types 100 in the inputField, the target object should be rotated to 90. Likewise from 0-100 Values to 0-90 degree. How to implement this??
Thanks, Jeeva
Answer by bubzy · Nov 27, 2015 at 12:25 PM
this is really simple maths :)
so you want 0-100 to be a percentage of 0-90.
float angleRef = (90/100)
then when you select the input its
float angleToRotate = angleRef * userInput; //or whatever you called it
transfom.eulerAngles = new Vector3(0,angleToRotate,0);
or whatever method you are using to rotate the object
Answer by Jeeva3m · Nov 30, 2015 at 10:37 AM
Hi bubzy,
Thanks a lot for the answer.. I also tried a bit similar to yours like following
=(Input/100)*90
for an example, if the user input is 100, (100/100)*90=90 so the object rotates to 90.
Jeeva
great, im glad it worked for you and that you were able to expand on it, well done :D