2026-05-14 2D Platformer Game 캐릭터 이동

This commit is contained in:
2026-05-14 18:01:14 +09:00
parent ea31d5a4e0
commit 764bc305f7
10 changed files with 450 additions and 14 deletions

View File

@@ -0,0 +1,41 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour, GameInput.IPlayerActions
{
public static InputManager Instance { get; private set; }
private GameInput _input;
public event Action<Vector2> OnMove_Event;
public event Action OnJump_Event;
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
_input = new GameInput();
_input.Player.SetCallbacks(this);
}
private void OnEnable() => _input?.Player.Enable();
private void OnDisable() => _input?.Player.Disable();
private void OnDestroy() => _input?.Dispose();
public void OnMove(InputAction.CallbackContext ctx)
{
OnMove_Event?.Invoke(ctx.ReadValue<Vector2>());
}
public void OnJump(InputAction.CallbackContext ctx)
{
if (ctx.phase == InputActionPhase.Started)
OnJump_Event?.Invoke();
}
}