I am making a mini map Using render texture to render my Over head cam to my screen and Drawing that texture using NGUI 3.9 every things is fine Apart from When i am Trying to click on My minimap and trying to destroy a object or Geting the point on my Game Floor which is on my World Space rendered by Main Camera Raycast is not reaching it some how i don't know what i am doing wrong Edited: I am using Ngui is because whole Gui of my game is in Ngui so its my requierment
I have Edited my code to a new aproch by this i am able to cast a ray on to my floor but the position of my ray is not accurate
here is my code
public void TestWithTextureCoords()
{
Camera main = UICamera.mainCamera;
Camera mapCam = transform.GetComponent<Camera>();
Ray firstRay = main.ScreenPointToRay(Input.mousePosition);
Debug.DrawLine(firstRay.origin, firstRay.direction);
RaycastHit textHit;
if (Physics.Raycast(firstRay, out textHit, main.farClipPlane))
{
var hitPoint = textHit.point;
Ray scondRay = mapCam.ViewportPointToRay(hitPoint);
RaycastHit worldHit;
if (Physics.Raycast(scondRay, out worldHit, mapCam.farClipPlane))
{
Debug.DrawLine(scondRay.origin, worldHit.point, Color.red);
Debug.Log(" world hit point " + worldHit.point);
Debug.Log(worldHit.transform.name, worldHit.transform);
}
}
}
Please look into it As soon as possible let me know a work around or how it is being done May be I am missing a small Think I have no idea about I have Tried different kind of approaches but all in vain help!