i am making script something like in swing copters when player moves to Left to right when you touch the screen , but its on X asis , i made my script on Y Axis , But it only goes down when i touch screen , it just doesnt go up at all , Please help
void MovePlayerOnYAxis()
{
foreach (Touch touch in Input.touches)
{
WasTouched = !WasTouched;
if (WasTouched)
{
if (Input.touchCount == 0)
{
WasTouched = false;
transform.localScale = new Vector3(1, 1, 1);
}
}
else
{
if (Input.touchCount > 0)
{
WasTouched = true;
transform.localScale = new Vector3(1,-1, 1);
}
}
huongbay = transform.localScale.y;
}
transform.root.Translate(Vector3.up * speed * huongbay * Time.deltaTime);
}
Input script
bool WasTouchedOrClicked()
{
if(Input.GetButtonUp("Jump") || Input.GetMouseButtonDown(0) ||
(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
return true;
else
return false;
}