#get object rotation values X Y Z 0-360 degrees to send over OSC/UDP (to another application)

1 messages · Page 1 of 1 (latest)

deep vector
#

Hi @plain brook & @sacred totem , thank you for your help yesterday. I have been working on it now and I can not get it right.

The only values I get is -1 to 1 for first 180 (0-180) degrees and then going opposite direction for the next 180 (180 to 360) degrees. I tried to come up with some equation using the x y and z values to make the numbers go in only one direction but alas I am not a mathematician.

If I ask like this: How do you find out if an object is turning to the left or to the right, and the angle (pan left/right) of this?

#

get transform.rotation to another application 0-360 degrees, or "Pan Left Right"

#

get object rotation values X Y Z 0-360 degrees to send over OSC/UDP (to another application)

plain brook
#

I suspect you dont quite understand what a direction vector represents so I would look that up. There are plenty of resources on google on how to calcultate the angles between 2 vectors

deep vector
#

yes I am trying and googling... give me a little hint plz

plain brook
#

google
what is a 3d direction vector
calculate angle offset from 3d direction vector

deep vector
#

I get the impression that I should make sure I send Euler angles out, and have Unity do the conversion quaternion to euler.
The tutorials I find are aimed at rotating objects, not getting the rotation values.
Thanks for the search terms

plain brook
#

As I already said you cannot use the Euler values from Unity. They are derived from a Quaternion and therefore cannot be relied upon to give consistent values because of the way Quaternion math works

#

And Quaternion values are meaningless outside of a Quaternion

deep vector
#

I will read some before I ask you more, but from this it sound to me like an impossible task then. But since you can actually see these values in the editor I would figure that you could get them. I mean shouldnt game devs want to find out if a player or object is turning to the left or right every now and then?

plain brook
sacred totem
deep vector
#

//pseudo code

//using transform.forward to figure out object Y rotation degrees 0-360

//------------ compass ------------

// Z range -1 to 1
// X range -1 to 1

// if Z > 0 = North == a
// if Z < 0 = South == a

// if X > 0 = East == b
// if X < 0 = West == b

// direction == a+b

// ----------- 0-360 Y rotation, or Z angle ------------

// if Z > 0 and X > 0
// degree == X [NE]

//if Z > 0 and X < 0
// degree == X [NW]

//if Z < 0 and X > 0
// degree == 2 + X [SE]

//if Z < 0 and X < 0
// degree == 2 + X [SW]

//else degree == 0

#

This is what I came up with looking at the video

#

a text adventure compass

#

But this cant be the sensible way of getting the orientation of an object