- Home /
Question by
SebGM2019 · Sep 29, 2018 at 02:55 AM ·
scripting problem
Slide VS Touch
Hi, I have a game where you slide some stuff and when you find the special one. Instead of sliding you need to just tap on it. For this I created the following code, but it's not working as I wanted to:
void Update()
{
if (Input.touchCount > 0)
{
// get the first one
Touch firstTouch = Input.GetTouch(0);
// if it began this frame
if (firstTouch.phase == TouchPhase.Began)
{
if (firstTouch.position.x > screenCenter)
{
Anim.SetBool("Swiper", true);
print("Swipe");
}
}
else if (firstTouch.phase == TouchPhase.Stationary)
{
if (E.FInt == 1)
{
//Sound
print("Debugged");
SceneManager.LoadScene(Beh.SceneArray[Beh.Counter]);
}
}
}
}
The problem here is that it executes the code of when you slide even if you just tap. Can someone help me?
Comment
Your answer