Hello everyone,
I have made a GUI texture for a semi circle with an arrow at the top of the semi circle.
I have made it able to be rotated arund a point using this code:
var Targeter : Texture2D;
var Gdepth : int = 0;
var rotAngle : float = 0;
private var pivotPoint : Vector2;
var Scaler = 0.00;
var alpha = 1.00;
function OnGUI() {
GUI.color = new Color(1,1,1, alpha);
GUI.depth = Gdepth;
pivotPoint = Vector2(Screen.width/2,Screen.height/2);
GUIUtility.RotateAroundPivot (rotAngle, pivotPoint);
GUI.DrawTexture(new Rect ((Screen.width/2)-(50*Scaler), (Screen.height/2)-(62*Scaler), (50*Scaler)*2, (50*Scaler)), Targeter, ScaleMode.ScaleToFit);
rotAngle ++;
}
however instead of just rotating I want to be able to make the rotation of it equal to a value that is dependent on the point of collision of a bullet with my character collider
For example if the bullet collider that hit me hit my collider at the front the GUI would have a rotation of 0
if I was hit from the left, rotAngle = 270
if I was hit from the right, rotAngle = 90
if I was hit from behind, rotAngle = 180
I am guessing I would use something like ContactPoint, Collision.contacts or ControllerColliderHit.point
but I'm not sure on the best way forward
any help would be much appreciated
Thanks Scribe