본문 바로가기

Unreal Engine 4/C++

<Unreal C++> 54 - Action RPG (TwoHand Mode)

 

필요한 개념


* 노티파이 정리
EnableCombo : 콤보가능하도록(bEnable)
BeginAction : 다음동작으로 넘어감
EndAction : 현재 동작 중지하고, 변수들 초기값으로 세팅
Collision : 충돌 가능하도록 시작때 켜줌, 끝날때는 꺼줌

만약 1개 동작만 하고 싶다면(EndAction만 넣으면 됨)


<TwoHand Mode>
나중에 Trail 넣을꺼면 Collision을 위쪽으로 좀 늘려주면 된다.

* GreatSword Draw Montage 생성
2를 넣어서 합쳐준다.

UpperBody로 세팅해주고 Draw Notify 넣어준다.



* Slash1 Montage생성
FullBody로 세팅, Collision Notify, EndAction Notify 넣어준다.
얘는 1개로 해서 콤보를 안넣어 줄 것이다.

 



* DA_TwoHand를 세팅

* DA_TwoHand


* BP_CPlayer ActionComponent에 DA_TwoHand 세팅

 

 

* CPlayer 입력처리

PlayerInputComponent->BindAction("TwoHand", EInputEvent::IE_Pressed, this, &ACPlayer::OnTwoHand);
void ACPlayer::OnTwoHand()
{
	CheckFalse(State->IsIdleMode());

	Action->SetTwoHandMode();
}

 

 

 

 

 

CPlayer.h 수정된 내용


더보기
...

UCLASS()
class UONLINE_04_ACTION_API ACPlayer : public ACharacter, public IICharacter
{
	GENERATED_BODY()
    ...

private:
	void OnTwoHand();
};

 

 

 

 

 

 

 

CPlayer.cpp 수정된 내용


더보기
...

void ACPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	...
	PlayerInputComponent->BindAction("TwoHand", EInputEvent::IE_Pressed, this, &ACPlayer::OnTwoHand);
}


void ACPlayer::OnTwoHand()
{
	CheckFalse(State->IsIdleMode());

	Action->SetTwoHandMode();
}

 

 

 

결과