본문 바로가기
개발💻/Unity

[Unity] New input system 1 ( 개념 정리 )

by Sports Entrepreneur 2024. 4. 21.

New input system 이란

  • 다양한입력 장치 호환 : 모든 주요 입력장치를 하나의 프레임워크 아래에서 관리
  • 사용자 정의 및 확장성 : 개인화된 입력 설정을 쉽게 구성하고, 게임에 특화된 조작 방식을 디자인 가능
  • 강력한 멀티플레이어 지원 : 각 플레이어에 대한 독립적인 입력 설정을 통해 멀티플레이어 게임 개발 용이
  • 실시간 입력 동적 조정 : 게임 플레이 중에도 입력 방식을 변경할 수 있는 유연성을 제공
  • 최소 2019.1 이상의 버전 필요

출처 : Unity Blog

 

Input manager ( legacy )와 New input system의 차이

Input manager ( legacy ) 

New input system

1. 풀링 기반
 - Input Manager는 'Update()' 함수를 사용하여 매 프레임마다 입력을 체크하는 풀링 방식을 사용
 - 입력 상태를 매 순간 확인해야 할 때 유용

2. 제한적인 커스터마이즈
 - 입력은 Unity 에디터 내의 'Input' 설정을 통해 사전에 정의
 - 동적으로 바인딩을 변경하기 어려움

3. 장치 제한
 - 각 입력 장치는 고유한 API를 가지고 있음
 - 크로스 플랫폼 입력 처리에 제한이 있음

4. 다중 플레이어 설정 복잡
 - 여러 플레이어를 위한 입력을 설정하는 것이 복잡함
 - 각 플레이어마다 입력을 구성하는 것이 까다로울 수 있음
1. 이벤트 기반
 - 새로운 시스템은 이벤트 기반으로 동작
 - 입력이 발생했을 때만 반응하여 리소스를 덜 사용하고 성능이 좋음.

2. 유연한 커스터마이즈
 - 개발자는 'Input Actions'를 통해 입력을 세밀하게 컨트롤 할 수 있음
 - 실행 중에 바인딩을 쉽게 변경 가능

3. 향상된 크로스 플랫폼 지원
 - 하나의 API를 통해 다양한 입력 장치와 플랫폼을 지원
 - 각 장치를 위한 고유한 설정 없이도 동작

4. 다중 플레이어 지원 간소화
 - 각 플레이어마다 입력 장치를 쉽게 할당
 - 다중 플레이어 게임 개발이 간편화

5. 디버거 및 툴 지원
 - 입력을 실시간으로 모니터링하고 디버깅 할 수 있는 강력한 도구 포함 

 

  • Input manager ( legacy ) 예시
// Input manager ( legacy ) 코드

void Update()
{
	// 키보드 입력값
    flaot h = Input.GetAxis("Horizontal");
    flaot v = Input.GetAxis("Vertical");

	Vector3 moveDir = (Vector3.forward * v) + (Vector3.right * h);
	transform.Translate(moveDir.normalize * Time.deltaTime * moveSpeed);

	// 점프 키 입력 여부 확인
    if(Input.GetKey(KeyCode.Space))
    {
    	// 점프 로직 실행
    }
}

 

  • New Input system 예시


New input system의 단점

  • 학습 곡선 : 새로운 시스템은 기존 시스템과 매우 다르므로, 이전 방식에 익숙한 개발자에게는 새로운 개념과 방식을 배우는 데 시간이 필요
  • 설정의 복잡성 : 초기 설정과 구성이 복잡할 수 있으며, 간단한 프로젝트의 경우 과도한 설정으로 느껴질 수 있음
  • 문서화와 자료 부족 : 새로운 시스템이 상대적으로 새롭기 때문에, 커뮤니티와 문서화된 자료가 아직은 기존 시스템에 비해 부족할 수 있음
  • 이전 버전과 의 호환성 문제 : 구 버전의 Unity 프로젝트를 새로운 입력 시스템으로 마이그레이션하는 데 어려움을 겪을 수 있으며, 호환성 문제가 발생할 수 있음
  • 추가적인 패키지 의존성 : 새 입력 시스템은 별도의 패키지로 제공되므로, 이를 프로젝트에 추가해야 됨

 

결론

전반적으로 새로운 입력 시스템은 강력하고 유연하지만, 기존 시스템에서 전환하는 데 있어 일정한 노력과 시간이 필요합니다. 특히, 크로스 플랫폼 게임 개발 또는 다중 입력 소스를 효과적으로 관리해야 하는 복잡한 게임 프로젝트에는 큰 이점을 제공합니다.

 

출처

https://blog.unity.com/en/engine-platform/introducing-the-new-input-system

 

Introducing the new Input System | Unity Blog

The Input System is built from the ground up with ease of use, consistency across platforms, and flexibility in mind. Today, we’d like to invite you to try it out and give us feedback ahead of its planned release alongside Unity 2020.1. The minimum requi

blog.unity.com

https://www.kodeco.com/9671886-new-unity-input-system-getting-started

 

New Unity Input System: Getting Started

In this Unity Input System tutorial, you’ll learn how to convert player input in your existing projects from the old Input Manager to the new Input System.

www.kodeco.com

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Actions.html?source=post_page-----a6c9cb100808--------------------------------#creating-actions

 

Actions | Input System | 1.0.2

Actions Related pages: Input Actions are designed to separate the logical meaning of an input from the physical means of input (that is, activity on an input device) that generate the input. Instead of writing input code like this: var look = new Vector2()

docs.unity3d.com

https://zerotomastery.io/blog/unity-new-input-system/

 

Unity's New Input System (+ How To Use It!) | Zero To Mastery

Confused with how to set up the new Unity Input System, or why you should use it vs the Input Manager 😕? I cover this and more, in this step-by-step tutorial.

zerotomastery.io