Answer the question
In order to leave comments, you need to log in
How to work with Touch in Unity?
I'm trying to make the car go using the Touch phase. But it doesn't work. Although when using the computer buttons, all functions work. What's my mistake?
private void Update()
{
if (Input.touchCount > 0)
{
float _pos;
float _startPos = 0f;
Touch _touch = Input.GetTouch(0);
if (_touch.phase == TouchPhase.Began)
{
_startPos = _touch.position.x;
Debug.Log(string.Format("_startPos = {0}", _startPos));
}
else if (_touch.phase == TouchPhase.Moved)
{
inputX = 1;
inputY = 1;
Move();
Turn();
AnimatWheels();
Debug.Log(string.Format("InputX = {0}, InputY = {1}", inputX, inputY));
}
else if (_touch.phase == TouchPhase.Ended)
{
Debug.Log("Ended");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question