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.
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.
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