A while back I’ve made a PC endless runner game. Now I want to convert to mobile but I cannot wrap my head around how to convert the controls from A/D to left/right buttons for mobile
This is the script which controlls the player:
public float speed = 1;
public float maxSpeed;
public Rigidbody rb;
public bool PlayerIsAlive;
public Vector3 movement;
public SpawnManager spawnManager;
// Start is called before the first frame update
void Start()
{
PlayerIsAlive = true;
rb = this.GetComponent<Rigidbody>();
}
void FixedUpdate()
{
moveCharacter(movement);
movement = new Vector3(Input.GetAxis("Horizontal"), 0, 1.9f);
movement = Vector3.ClampMagnitude(movement, 1);
}
public void moveCharacter(Vector3 direction)
{
rb.MovePosition(transform.position + (direction * speed * Time.deltaTime));
}
private void OnTriggerEnter(Collider other)
{
spawnManager.SpawnTriggerEntered();
}