using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    public PlayerInputController playerInputController; //输入事件

    public Rigidbody2D rb;

    public Vector2 inputDirection;//输入方向的数值
    public float moveSpeed;//速度
    private void Awake()
    {

        playerInputController = new PlayerInputController();
        rb = GetComponent<Rigidbody2D>();
    }

    void Start()
    {

    }

    private void OnEnable()
    {
        playerInputController.Enable();
    }

    private void OnDisable()
    {
        playerInputController.Disable();
    }


    void Update()
    {
        inputDirection = playerInputController.GamePlayer.Move.ReadValue<Vector2>();//读取数值  //wasd移动

    }



    private void FixedUpdate()
    {
        Move();
    }

    public void Move()
    {
        rb.velocity = new Vector2(inputDirection.x * moveSpeed, inputDirection.y * moveSpeed); //wasd移动


    }
}