- Home /
calculate the angle live
I want to see live the angle with grads between 2 objects on a guitext. From the few i know i did that with target.transform.eulerAngles.y and multiplied with 1.11111111 so i can get the grads. I want to hit m and then start counting the angle from 0. I also did that. The problem is when for example i hit m at 200 grads i get the zero, but when i rotate more than 200 then it shows me a minus result. I want that to continue up to 400. Maybe it's easier than i make it look. Here is my code so far:
var Degrees : float; var Grads : float; var CurrentAngle : float; var NewAngle : float; var target : Transform;
function Start () {
Degrees = target.transform.eulerAngles.y;
CurrentAngle = 0;
}
function Update () {
Degrees = target.transform.eulerAngles.y;
Grads = Degrees * 1.11111111;
guiText.text = " "+Grads +" Grads";
if (Input.GetKey ("m"))
CurrentAngle = Degrees;
NewAngle = target.transform.eulerAngles.y - CurrentAngle;
Grads = NewAngle * 1.11111111;
guiText.text = " "+Grads +" Grads";
}
Comment