I’m making a small plane with a code like:
“transform.position = Camera.main.ScreenToWorldPoint( new Vector3(Input.mouseposition.x, Input.mouseposition.y, 10f )”.
10f due to the plane are 10 unit far from the camera.
The plane have the same position with the mouse.But when I attach a 512 x 512 RenderTexture to the camera and show the Rendertexture on another plane as a material, the plane are not exactly having the same position with the mouse in x axis ( in y it’s right). What’s wrong I have done?
Thanks a lot
Hsin
maybe this helps you. cast a ray through your mousepointer and directly determine its uv-position at the texture of your object.
Thanks a lot for your reply, and yet I just used a temporary measure to solve the problem by just dividing the x coordinate by 1.5 .
The RenderTexture size is 1:1 and my Camera’s aspect ratio is 3:2. After I attached the rendertexture to the camera, the camera’s apsect ratio also changed to 1:1 , and the RenderTexture range is smaller than one is shown by camera with no RenderTexture. Maybe Camera.main.ScreenToWorldPoint has deflection due to that?
Could anyone tell me any better solution?
Thanks a lot
hsin