Hello! Firstly I started with watching Unity tutorial video about “Tanks” - where was created nice non-interactive minimap. Following instructions I create square minimap 180X180 in -100X100 position to right bottom corner of the screen. My minimap camera has orthograthic projection with width 100. Also I turned off phisics for minimap layer, so markers dosen’t stop main camera moving even they have colliders. Now I wrote a code attached to minimap for interactivity of markers:
using UnityEngine;
using UnityEngine.EventSystems;
public class MiniClick : MonoBehaviour, IPointerClickHandler
{
[SerializeField] private Transform camBody;
public void OnPointerClick(PointerEventData EventData)
{
float miniX = -(EventData.pressPosition.x - Screen.width + 100.0f) / 90.0f * 100.0f;
float miniY = -(EventData.pressPosition.y - 100.0f) / 90.0f * 100.0f;
Vector3 newPos = new Vector3(camBody.transform.position.x + miniX, 60.0f, camBody.transform.position.z + miniY);
var ray = new Ray(newPos , Vector3.down);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.GetComponent<MiniSphereScript>())
{
//Where code for marker sphere
}
else
camBody.transform.position = newPos;
}
}
}
Where camBody is camera. But this solution works only for isometric game because rotation ruined all coordinate transition. My question is how to do this but 3D with rotation around Y axis? Maybe someone has ideas?