Hey guys…
I have my game, already… but I want to add a few buttons for touch control capabilities, so I can import it to phones and tables…
Now, my 1st problem is that the button does not appear… so, my second problem (check if it works) is impossible, because of the first issue…
Any help, please?
Here is what I have:
if (keyboard)
{
if (Input.GetButtonDown("Fire1"))
{
Instantiate(bullet, transform.position, transform.rotation);
}
// Debug.Log(transform.localPosition.x);
if (Input.GetButton("Horizontal"))
{
if (transform.localPosition.x < leftBorder + 1f)
{
moveX = 0.018f;
}
else if (transform.localPosition.x > rightBorder - 1f)
{
moveX = -0.018f;
}
else
{
moveX = (moveSpeed * Time.deltaTime * Input.GetAxis("Horizontal"));
}
if (moveX < 0)
{
animator.SetInteger("Direction", 1);
}
else if (moveX > 0)
{
animator.SetInteger("Direction", 2);
}
else if (moveX == 0)
{ animator.SetInteger("Direction", 0); }
}
transform.Translate(moveX, moveY, 0);
}
else
{
Debug.Log("I am false");
GUI.depth = 0;
if (GUI.Button(new Rect(Screen.width * .5f, Screen.height * .5f, Screen.width * .1f, Screen.height * .1f), "", _leftArrow))
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Stationary)
{
animator.SetInteger("Direction", 1);
this.transform.Translate(Vector3.left * 7.0f * Time.deltaTime);
}
}
}
Thanks!!!