Question by
theismailarsln · Feb 20, 2017 at 07:35 PM ·
androidinputcharactercontrollertouch controlscontrol
Moving character with touch buttons (Android)
Hello friends I am developing new 2d game. (The game is like a flappy bird but it's just left-right button that goes to itself)
But compared to the problem: the game on the keyboard does not work on touch to the left or right with the arrow keys.
I looked at Har source. Nor are solutions to previous issues. I'm glad you helped me.
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class CharacterControl : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxisRaw("Horizontal");
transform.Translate(new Vector2(h * Time.deltaTime * 5, 0));
}
void OnCollisionEnter2D(Collision2D col)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
Comment