rotating minimap compass according to character direction

How would I script in Javascript to rotate a GUITexture using the OnGUI function according to which direction my character is facing? I have a North, south, east, west compass that I am trying to rotate on a minimap to show which direction the character is facing.

Something like this should do the trick:

`
var playerDirection : Vector2 = ( 0, 1 );
var playerTransform : Transform;
var deltaRotation : float = 0;
var pivotPoint : Vector2;
//pivotPoint is the center of your compass texture

function OnGUI() { deltaRotation = Vector2.Angle( playerDirection, Vector2( playerTransform.forward.x, playerTransform.forward.z ) ); GUIUtility.RotateAroundPivot( deltaRotation, pivotPoint ); playerDirection = Vector2( playerTransform.forward.x, playerTransform.forward.z ); //Plus whatever other code you need for the custom control }

` It's not perfect as is, but with a little adaptation it should work for you.