using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { private Rigidbody2D rb; public float speed; // Start is called before the first frame update void Start() { rb = GetComponent(); } private void FixedUpdate() { float moveHorizontal = Input.GetAxis("Horizontal"); Vector2 movement = new Vector2(moveHorizontal, 0f); rb.velocity = movement*speed; } }