Hello,
I started off with keyboard controls, but I need to change to touchscreen. However, I don’t know how to go about doing this, as changing my movement script will impact my game and cause me to restart which I really do not want to do at this point. Any advice or help? Here is my movement script
I was thinking of adding buttons to the screen and on button click the player would move or jump accordingly.
void FixedUpdate()
{
float move = Input.GetAxis("Horizontal");
//Movement
if (Input.GetKey("right")) rb.velocity = new Vector3(move * runSpeed, rb.velocity.y, 0);
if (Input.GetKey("left")) rb.velocity = new Vector3(-move * -runSpeed, rb.velocity.y, 0);
//Jumping
if (Input.GetButton ("Jump") && isGrounded()) {
anim.SetTrigger ("isJumping");
rb.velocity = new Vector3 (rb.velocity.x, jumpHeight, 0);
}
}
Many thanks