using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public float moveSpeed = 5f; private Rigidbody2D rb; private Vector2 movement; private void Start() { rb = GetComponent(); } void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); } private void FixedUpdate() { rb.velocity = (movement * moveSpeed); } }