2025-04-04 09:35:44 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2025-04-07 21:57:07 +08:00
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
using UnityEngine.InputSystem.XR;
|
2025-04-04 09:35:44 +08:00
|
|
|
|
|
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
|
|
|
{
|
2025-04-07 21:57:07 +08:00
|
|
|
|
public PlayerInputController playerInputController; //<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
|
|
|
|
|
public Rigidbody2D rb;
|
|
|
|
|
|
|
|
|
|
public Vector2 inputDirection;//<2F><><EFBFBD>뷽<EFBFBD><EBB7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
public float moveSpeed;//<2F>ٶ<EFBFBD>
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
playerInputController = new PlayerInputController();
|
|
|
|
|
rb = GetComponent<Rigidbody2D>();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 09:35:44 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
2025-04-07 21:57:07 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
playerInputController.Enable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
playerInputController.Disable();
|
2025-04-04 09:35:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-07 21:57:07 +08:00
|
|
|
|
|
2025-04-04 09:35:44 +08:00
|
|
|
|
void Update()
|
|
|
|
|
{
|
2025-04-07 21:57:07 +08:00
|
|
|
|
inputDirection = playerInputController.GamePlayer.Move.ReadValue<Vector2>();//<2F><>ȡ<EFBFBD><C8A1>ֵ //wasd<73>ƶ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void FixedUpdate()
|
|
|
|
|
{
|
|
|
|
|
Move();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Move()
|
|
|
|
|
{
|
|
|
|
|
rb.velocity = new Vector2(inputDirection.x * moveSpeed, inputDirection.y * moveSpeed); //wasd<73>ƶ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
2025-04-04 09:35:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|