언리얼 엔진에서 제공하는 input mapping을 활용해
WASD로 character를 움직이고
마우스로 시야를 조작할 수 있도록 한다
input mapping은 AXIS mapping과 Aciton mapping이 존재한다
input을 수정하기 위해서는
Edit -> Project Settings -> Engine -> Input 를 따라 들어간다
사진처럼 Bindings에 키를 binding한다
다음으로 Main.cpp에 정의되어 있는 SetupPlayerInputComponent함수를 다음과 같이 정의한다
// Called to bind functionality to input
void AMain::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAxis("MoveForward", this, &AMain::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AMain::MoveRight);
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis("TurnRate", this, &AMain::TurnAtRate);
PlayerInputComponent->BindAxis("LookUpRate", this, &AMain::LookUpAtRate);
}
미리 구현했던 함수 (ex. &AMain::MoveForward,...) 를 arguemnt로 전달해 input에서 값을 받아 함수를 실행한다