Hi I am making a 2D Pong style game. At first I thought that mouse simulates touch movement but it seems that is not the case here. I wrote this code to move paddle by using mouse but it does not let me use it for touch on phone. I would like to have this code edited so that I can control my paddle with touch on phone. Android phone to be precise. I am a noob at C# and unity so please don’t judge me.
I am also a C# noobie so I am not sure if this would work, but try it, and if other members want to correct my code, they can.
EDIT: I think the code at line 34 is not going to work, if so, try instead:
if (distance > 100f)
{
//If you want the paddle to follow the mouse on X and Y, do:
Vector3 paddlePositionXY = new Vector3 (deltaX, deltaY, 0);
paddle.transform.position = paddlePositionXY;
//If you don't want the paddle to follow the mouse on Y, do:
Vector3 paddlePositionX = new Vector3 (deltaX, 0, 0);
paddle.transform.position = paddlePositionX;
hasSwiped = true;
}