캐릭터 움직임
This commit is contained in:
@@ -9,13 +9,14 @@ public class InputManager : MonoBehaviour, GameInput.ICharacterActions
|
||||
|
||||
private GameInput _input;
|
||||
|
||||
public event Action OnMoveNext_Event;
|
||||
public event Action<Vector2> OnMove_Event;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this; //만들어진 자신을 인스턴스로 설정
|
||||
DontDestroyOnLoad(gameObject); //씬이 바뀌어도 파괴되지 않도록 설정
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -33,7 +34,9 @@ private void Awake()
|
||||
|
||||
public void OnMove(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if (ctx.phase == InputActionPhase.Performed)
|
||||
OnMoveNext_Event?.Invoke();
|
||||
// Performed만 받으면 키를 뗐을 때(Canceled) 0이 전달되지 않아 계속 움직인다.
|
||||
// Canceled의 ReadValue는 Vector2.zero를 돌려준다.
|
||||
if (ctx.phase == InputActionPhase.Performed || ctx.phase == InputActionPhase.Canceled)
|
||||
OnMove_Event?.Invoke(ctx.ReadValue<Vector2>());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user