using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float speed; private Rigidbody2D rb; private Vector2 moveVelocity; void Start() { rb = GetComponent(); } void Update() { Vector2 movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); moveVelocity = movement.normalized.normalized * speed; } private void FixedUpdate() { rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime); } }