Relative Rotation to an Object
I've been trying to get the values of a rotation to an audiosource so that I can get a value which will effect the filter. Here is what I'm trying to do.
Facing left would also be ninety degrees and facing away would be 180. I want to get all relative float values when my player camera is nearing or headed away from the sound source.
I have figured out how to get values relative to it's angle so imagine the principle is very much the same in terms of getting the values I want. Anybody know of a way to get these rotation values no matter where my player is in the worldspace?
(Code for distance-angle)
float angle = Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg;
if(angle > 90){
float reverseAngle = (90 - angle) + 90;
lowPass.cutoffFrequency = (reverseAngle/180 * 22000);
}
if(angle < 90){
lowPass.cutoffFrequency = (angle/180 * 22000);
}
Answer by GoodGuyA · Oct 12, 2015 at 05:15 PM
I found the answer here:
http://forum.unity3d.com/threads/using-vector3-dot-for-direction-facing-calculation.173707/
It's as simple as using the values accordingly. The value output is from around -1 to 1, though in radians. You can find the relative rotation to any single object using this.
Answer by GoodGuyA · Oct 12, 2015 at 05:15 PM
I found the answer here:
http://forum.unity3d.com/threads/using-vector3-dot-for-direction-facing-calculation.173707/
It's as simple as using the values accordingly. The value output is from around -1 to 1, though in radians. You can find the relative rotation to any single object using this.
Your answer
Follow this Question
Related Questions
Tank Turret facing away from me 1 Answer
How to Stack, Shuffle and deal cards 0 Answers
Unity 3D - Make player rotate based on the mouse position in New input system/Character Controller 0 Answers
How would I orient VTOL engines relative to the direction of a ship's movement? 1 Answer
The direction my camera is rotating should indicate the direction my object facing 0 Answers