Move Fighter Plane on touch.

Fighter Plane is at y = 100 and my camera is above plane at y = 102;
I want to move plane horizontally.
where ever user touch plane must travel to that position.
As per code, my plane is moving horizontally in a proper manner but as camera is much above the plane so effect seen is much less.

Below is code :

//planeCamera is camera above plane.

Vector3 newPosi = planeCamera.ScreenToWorldPoint (new Vector3(Input.mousePosition.x,Input.mousePosition.y,planeCamera.nearClipPlane));

Vector3 temp = Vector3.Lerp (transform.position,newPosi ,3 * Time.deltaTime);

transform.position = new Vector3 (temp.x, transform.position.y, temp.z);

when instead of this
transform.position = new Vector3 (temp.x, transform.position.y, temp.z);
i do
transform.position = new Vector3 (temp.x, temp.y, temp.z);
everything works fine except that plane comes very much close to camera that it is seen partially.

I don’t want that plane changes it Y position.
Thank you.

Hi,

It has to do with the fact that you are setting the Y value to that of the near clipping plan e of the camera. Hence, because the origin of your object is most likely not the top of it, anything above the origin, will not be rendered as it goes past the near clipping plane of the camera.

This is really easy to fix, all you have to do is subtract some value from that of the near clipping plane, in order to move the plane origin slightly down so that the rest of your plane is also below the clipping plane.

Good Luck, hope this helped :slight_smile:

IEMatrixGuy out.