I can only move the player a little bit per keypress. Is there a way i can make it so that I constantly move, for as long as A or D is held down?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
public class PlayerController : MonoBehaviour
{
public float speed;
private Rigidbody2D rb;
void Update () {
if (Input.GetKeyDown (KeyCode.A))
{
transform.Translate (-Vector3.right * Time.deltaTime * speed);
}
if (Input.GetKeyDown (KeyCode.D))
{
transform.Translate (-Vector3.right * Time.deltaTime * speed);
}
}
}