i’v got a wheel connected to the panel with a character joint so wheel is turning round its z axis, i’ve attached a drag rigidbody script to it so the player can rotate the wheel.
My problem is that i want to be able to move door up when z angle of the wheel is for example > 150degs.
i need a hint how to “read” the rotation of the wheel.
The pseudocode looks like this -
var turn : boolean = false;
func update
if z angle of a wheel is > 150 degrees
turn == true;
and than i’ll pass this bool to the door’s script. The problem is how to write it “grammatically”.
thanx for any hints.
Rotations are stored internally as Quaternions and not a normal Vector3.
Its something like
Vector3 theRotation = transform.localRotation.eulerAngles;
Plenty of code snippets on
Just look at Quaternion, Euler, Transform docs.
Thanx for a hint works fine!
var tr : Transform;
var open: boolean = false;
function Update () {
if (tr.transform.eulerAngles.z >150){
open = true;
Debug.Log ("opened");
}
else if (tr.transform.eulerAngles.z <150){
open = false;
Debug.Log ("closed");
}
}