Hello. Can somebody explain how can I redo this code so I can make my game work for touchscreens. Thanks in advance!
#pragma strict
var moveUp : KeyCode;
var moveDown : KeyCode;
var speed : float = 10;
function Update ()
{
if (Input.GetKey(moveUp))
{
rigidbody2D.velocity.y = speed;
}
else if (Input.GetKey(moveDown))
{
rigidbody2D.velocity.y = speed * -1;
}
else
{
rigidbody2D.velocity.y = 0;
}
rigidbody2D.velocity.x = 0;
}
Hey,
Here is a link to the script doc info on touch input.
It looks as if the first example may give you what you need (Touch with move direction).
There is much more info on touch processing as you look around the docs.
Hope it helps.
Question solved by @JeffreyD, please use the Forums for programming discussions. Adding this answer to remove it from the Unanswered view and give more relevance to other questions requiring attention. Thanks for your comprehension, Unity Support.