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);
	}

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.

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.