hello everyone and thanks for the help. I made this switch script that switch between 2 characters (both childs of an empty object) by touching the right half of the screen. My problem is that if i touch repeatedly the right half of the screen, the script will be able to keep up, but it wont change the texture. I’ll use an example to explain me better, lets say i have a red and a green circles as my 2 characters. If i touch too fast the screen it’ll change between the green and the red one but in the game mode it will take something like 1 second to change the texture from red to green or viceversa, so it makes the game confusing (even if it works). Here is my code:
int attivo = 1;
public void Update()
{
foreach(Touch touch in Input.touches)
{
if(touch.position.x > Screen.width / 2 && touch.phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject())
{
switch (attivo)
{
case 1:
attivo = 2;
rosso.gameObject.SetActive(false);
verde.gameObject.SetActive(true);
break;
case 2:
attivo = 1;
verde.gameObject.SetActive(false);
rosso.gameObject.SetActive(true);
break;
}
}
}
}
how can i do that?