Hi all,
I have a camera which is like an Arial Camera. I am trying to select the point from mouse click but the behavior is not predictable. I am using following code to get the selected coordinates -
Vector3 targetpos;
float myPoint;
private Plane plane = new Plane(Vector3.up,0);
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.mainCamera.ScreenPointToRay (Input.mousePosition);
if (plane.Raycast (ray, out myPoint)) {
targetpos = ray.GetPoint (myPoint);
}
}
The problem is its not giving me the correct point.
Is it the correct way to get the mouse clicked coordinate from arial camera?
What changes should i do for getting correct solution , because this solution works correctly when applied for third person camera view.
I have also tried Physics.Raycast but both gives me a selection away from my mouse click region.
Little more explanation -
I am trying to build a AI mover , now to move from its own location to other location it need the point (x,y,x) to travel to. This “travel to” point i am trying to select from a camera view (in this case camera is situated in the sky proving static view of the model) . Now with the above mentioned code i am trying to get my “travel to” point. It do give me point selected (x,y,z) but not at the exact spot where i selected it but elsewhere.