Minimap rotating nodes

Hey there !

I’m working on a minimap system and I’m stuck at a point. My minimap is working fine, but I’d like to improve it by rotating the nodes, which are displayed on the map.

Here’s what I’ve done so far.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MiniMap : MonoBehaviour {
	public Texture building, arrow;

	private Rect buildingRect;

	private GameObject[] objects;
	private GameObject player;

	// Use this for initialization
	void Start () {
		objects = GameObject.FindGameObjectsWithTag("Objects On Map");
		player = GameObject.Find ("Player");
	}

	void OnGUI () {
		foreach (var obj in objects) {
			if (Vector3.Distance(obj.transform.position, player.transform.position) < 100) {
				buildingRect = new Rect((100 + (obj.transform.position.z - player.transform.position.z )),300 + ( obj.transform.position.x - player.transform.position.x ) , 10,10);
				GUI.DrawTexture(buildingRect, building);
			}
		}

		GUI.DrawTexture(new Rect(100, 300, 10,10),arrow);
	}
}

For now I’m displaying all nodes from a for each cycle, and it’s only for testing purposes. I was playing around with either adding or subtracting the eulerangles.y from the displayed nodes X and Z coordinates but hence I don’t know that much about that part of math, I’m asking for your help.

I think I’m on the right way to go, but would need a push to continue developing my system.
Thanks in advance !

You need to decide on some central point (which you rotate around), then this function can rotate around that point (hopefully! untested…):

Vector3 RotatePoint(Vector3 point, Vector3 centre, Vector3 axis, float angle){
	Vector3 offset = point - centre;
	Quaternion q = Quaternion.AngleAxis(angle, axis);

	Vector3 newPos = centre + (q*offset);
	return newPos;
}

and so you could call it as:

Vector3 newPoint = RotatePoint(currentPoint, Vector3.zero, Vector3.up, 30f);