foreach (Touch input in Input.touches)
{
if (input.phase == TouchPhase.Moved)
{
Vector3 screenPoint = new Vector3 (Input.mousePosition.x, 65);
screenPoint.z = 11; //distance of the plane from the camera
transform.position = Camera.main.ScreenToWorldPoint(screenPoint);
}
}
The object follows the touch, but how do I get it moving with a velocity from position A to position B?
That would be a completely different question. You will have to set different variables for each player, or even better, put the component in both player objects. Once done that, you have to control the touches to see which player has done the input, which depends on how you detects which player has done it. If you can, please accept the answer for this question. For more insight on how to detect which player has done an input, post another question.
That's great! it works perfectly! I heartily thank you <3
ā ArditoThis script works for one player, but for two players playing versus?
ā ArditoThat would be a completely different question. You will have to set different variables for each player, or even better, put the component in both player objects. Once done that, you have to control the touches to see which player has done the input, which depends on how you detects which player has done it. If you can, please accept the answer for this question. For more insight on how to detect which player has done an input, post another question.
ā dmg0600