728x90
반응형
에디터에서 다음 경로로 이동합니다.
Edit → Project Settings → Input → Bindings
여기서 두 가지를 등록합니다.
Axis Mappings
- MoveForward
- MoveRight
- Turn
- LookUp
Action Mappings
- Jump
- Attack
- Interact
공식 문서에서도 입력 정의는 Action Mapping과 Axis Mapping을 통해 설정하는 방식으로 안내합니다.
- MoveForward
- W = 1.0
- S = -1.0
- MoveRight
- D = 1.0
- A = -1.0
- Turn
- Mouse X = 1.0
- LookUp
- Mouse Y = -1.0 또는 1.0
Action Mappings
- Jump
- Space Bar
- Attack
- Left Mouse Button
- Interact
- E
// PlayerCharacter.cpp
#include "PlayerCharacter.h"
#include "Components/InputComponent.h"
#include "GameFramework/Controller.h"
APlayerCharacter::APlayerCharacter()
{
PrimaryActorTick.bCanEverTick = true;
}
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &APlayerCharacter::MoveForward);
PlayerInputComponent->BindAxis(TEXT("MoveRight"), this, &APlayerCharacter::MoveRight);
PlayerInputComponent->BindAxis(TEXT("Turn"), this, &APlayerCharacter::Turn);
PlayerInputComponent->BindAxis(TEXT("LookUp"), this, &APlayerCharacter::LookUp);
PlayerInputComponent->BindAction(TEXT("Jump"), IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction(TEXT("Jump"), IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAction(TEXT("Attack"), IE_Pressed, this, &APlayerCharacter::Attack);
PlayerInputComponent->BindAction(TEXT("Interact"), IE_Pressed, this, &APlayerCharacter::Interact);
}
void APlayerCharacter::MoveForward(float Value)
{
if (Controller && Value != 0.0f)
{
AddMovementInput(GetActorForwardVector(), Value);
}
}
void APlayerCharacter::MoveRight(float Value)
{
if (Controller && Value != 0.0f)
{
AddMovementInput(GetActorRightVector(), Value);
}
}
void APlayerCharacter::Turn(float Value)
{
AddControllerYawInput(Value);
}
void APlayerCharacter::LookUp(float Value)
{
AddControllerPitchInput(Value);
}
void APlayerCharacter::Attack()
{
UE_LOG(LogTemp, Warning, TEXT("Attack"));
}
void APlayerCharacter::Interact()
{
UE_LOG(LogTemp, Warning, TEXT("Interact"));
}
Setting Up User Inputs in Unreal Engine | Unreal Engine 5.7 Documentation | Epic Developer Community
How to set up user input in Unreal Engine
dev.epicgames.com
728x90
반응형
'[ Unreal5 ] > - 언리얼엔진5 실습' 카테고리의 다른 글
| 언리얼엔진5 c++ MontageEnd (0) | 2026.03.09 |
|---|---|
| 스팀 게임 출시 가이드2 (UE 게임 Steam 업로드) (0) | 2026.01.27 |
| 언리얼엔진5 Lighting SpringArm을 통해서 충돌 구조 (0) | 2025.11.11 |
| 언리얼엔진5 Lighting Channels로 캐릭터 전용 라이트 분리하기(BP+C++) (0) | 2025.11.11 |
| 언리얼엔진5 c++ TMap과 Enum 한 번에 초기화하기 (0) | 2025.09.30 |
댓글