using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class PlayerMovement : MonoBehaviour { private Rigidbody2D rb; private Inputs Input; private InputAction Walk; private InputAction Jump; private InputAction Dash; private Vector2 Force; public float Speed; private void Awake() { Input = new Inputs(); rb = this.gameObject.GetComponent(); } private void OnEnable() { Walk = Input.Movement.wasd; Jump = Input.Movement.Jump; Dash = Input.Movement.Dash; Walk.Enable(); Jump.Enable(); Dash.Enable(); } private void OnDisable() { Walk.Disable(); Jump.Disable(); Dash.Disable(); } // Start is called before the first frame update private void Start() { } // Update is called once per frame private void Update() { Force = Walk.ReadValue(); rb.AddForce(new Vector2(Force.x * Speed * Time.deltaTime, 0), ForceMode2D.Impulse); } }