Touch Screen Issue

I have some new code. It works kinda but now my player object disappears when I move my object. Do I need to have this on a separate object or something for touch to work?

TargetFollow = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
            TargetFollow.z = transform.position.z;
            transform.position = Vector3.Lerp(transform.position, TargetFollow, speed * Time.deltaTime);

The ship moves it just goes invisible but still works because i can see the bullets shooting. Its a 2d space shooter

I would begin by printing out the values of transform.position and seeing how they vary when you touch the screen.

NOTE: the above code will only work if the camera is Orthographic. If it is perspective I don’t think you’ll get what you think you will get.

1 Like

I got it working thanks everyone