- Home /
Question by
pickle chips · Jun 27, 2013 at 02:54 PM ·
cameraminimapworldtoscreenpointgui.boxdot
Drawing a GUIBox on player/enemies in MiniMap
So I have a minimap, but instead of actually rendering the enemies and the player, I just want to draw a GUI box in their position instead, but I can't seem to get it to work. Here's how I tried to do it:
private GameObject player;
private GameObject[] enemies;
void Start () {
player = GameObject.FindGameObjectWithTag("Player");
enemies = GameObject.FindGameObjectsWithTag("Enemy");
}
void OnGUI() {
foreach (GameObject enemy in enemies) {
Vector3 pos = gameObject.camera.WorldToScreenPoint(enemy.transform.position);
GUI.Box(new Rect(pos.x,pos.y, 10, 10), "", dot);
}
Vector3 playerPos = gameObject.camera.WorldToScreenPoint(player.transform.position);
GUI.Box(new Rect(playerPos.x, playerPos.y, 10, 10), "", dot);
}
("dot" is a GUIStyle)
but No dots even appeared on the minimap.. Can anyone help me out please? Thanks
Comment