Hello everybody! I am new to Unity and and I am not sure how to use Touch. I created this block of code to make the boolean “jump” true when the player touches the screen. When I try to play I get an error that says:
ArgumentException: Index out of bounds.
CharacterControl.Update () (at Assets/C# Scripts/CharacterControl.cs:23)
Line 23 is “touch = Input.GetTouch (0);” I am not really sure how to fix this or improve so any suggestions are highly appreciated! Thanks in advance!
private Touch touch;
void Update(){
touch = Input.GetTouch (0);
switch (touch.phase) {
case TouchPhase.Began:
jump = true;
break;
}
}