- Home /
How to find position of plane relative to orthographic camera?
Hi Guys,
I want to stamp texture of one plane onto another plane.
I want to stamp texture of above plane at same position on to background plane. I am able to stamp texture but its not stamping on exact position. The position is getting on another position. How to find exact position on mouse button down. I tried to use Physics.Raycasr but still its not working. Btw I am stamping texture on mouse click.
it is very hard to do this well.
please read this long answer
http://answers.unity3d.com/questions/292333/how-to-calculate-swipe-speed-on-ios.html
please "Thumbs Up" the answer :)
Answer by robertbu · May 09, 2013 at 02:35 PM
You can calculate the position using Camera.ScreenToWorldPoint(). The third parameter of this function is the distance in front of the camera. So assuming you are looking down the 'Z' axis:
var dist = Mathf.Abs(Background.transform.postion.z - Camera.main.transform.position.z);
var v3 = Vector3(Input.mousePosition.x, Input.mousePosition.y, dist);
v3 = Camera.main.ScreenToWorldPoint(v3);
Note you may have to reduce 'dist' slightly to put the stamp in front of the background plane.
Answer by PushpaK · May 31, 2013 at 05:19 AM
Thanks for your help @robertbu
I used this function to get exact position of gameobject and it works well.
function Raycast (origin : Vector3, direction : Vector3, out hitInfo : RaycastHit, distance : float = Mathf.Infinity, layerMask : int = kDefaultRaycastLayers) : boolean
Your answer