티스토리 뷰
먼저, 자신의 함수의 생성에서 기본으로 들어가면 만약 자신의 AnimMontage를 실행하는 Server매크로 함수를 생성하고 싶을떄 다음과 같이 설정하면 된다.
.h
UFUNCTION(Server, Reliable, WithValidation)
void Server_TestFunction(uint8 DirectionIndex);
.cpp
oid ACharacterBase::Server_TestFunction_Implementation(uint8 DirectionIndex)
{
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (!AnimInstance || !RollMt) return;
AnimValues.bRoll = true;
const char* SectionList[] = { "Forward", "Left", "Right", "Back_L", "Back_R", "Dodge" };
AnimInstance->Montage_Play(RollMt);
AnimInstance->Montage_JumpToSection(FName(SectionList[DirectionIndex]), RollMt);
}
bool ACharacterBase::Server_TestFunction_Validate(uint8 DirectionIndex)
{
return true;
}
1. 기본적으로 자신의 생성하는 함수의 앞에 매크로의 이름을 붙이는게 젤 좋다. 이유는 해당함수가 그냥 일반적인 함수일수도 있고, Client등 자신이 원하는 매크로의 함수로 사용하거나 오버로딩적인 오류를 줄이기 위해서이다.
그래서 만약 Client면 Client_함수명, Server면 Server_함수명, Multicast = Multicast_함수명 이런식으로 함수명으로 만들어줘야한다. 사람마다 다른겠지만 대표적으로는 이렇게 많이 이용한다.
2. 그리고 _Implementation과 _Validate를 사용한다는것이다. 뜻으로 알수있듯이 Implementation = 구현하다, Validate = 확인 이라는 뜻을 가지며 기능적으로는 Implementation은 함수안의 기능을 구현하는것이며 Validate는 치트성을 검사하는것이다.
Validate를 시험해보고 싶으면 함수에서의 받은 인자값이나 기능적으로 다른 이상한 기능이 구현될경우를 operator로 검사해서 false로 반환하면 어떻게 되는지는 쉽게 확인 할수있다. (쉽게 확인할수 있으며 아래에 각 해당 매크로의 작동방식을 넣어놨기 때문에 굳이 영상은 없다.)
RPC에서의 가장 기본적으로 보는것은 어떤식으로 호출해서 실행을 할것인가이다.
모든 RPC에서의 호출은 Server->Multicast가 가장 일반적이다. 하지만 만약 해당 클라이언트의 값을 따로 적용하기 위해서는 Client도 혼용해서 쓰는게 가장 좋은 방법이다.
RPC구동방식모음. (RootMotion 사용중.)
https://www.youtube.com/watch?v=Yau8N1vPwLk
위의 영상들과 같이 Server -> Multicast의 반응은 해당 몽타주함수가 호출하는걸 알수 있다. 해당 함수를 호출하는데에 있어서 가장 기본적으로 호출되고 오직 Multicast만 호출시에는 Server에서 호출이 일어났을때는 각 클라이언트들에게 몽타주가 실행되지만 다른 클라이언트에서 자신소유의 클라이언트에서만 호출되고 다른 클라이언트들에게는 호출이 안되는걸 알수있다.
그래서 Server에서 NetMulticast가 호출된다는걸 알수 있다.
다른 얘기로는 본인은 AnimMontage를 이용하면서 RootMotion으로 이동을 하는데 Server만 호출하는 영상에서는 Server를 호출하면 위치는 업데이트되며 이동하는모습이 보이지만 Animation동작은 서버안에서만 호출된다. (이유는 위치는 서버에서 값을 받고 각 클라에게 전달을 하지만 Animation은 AnimInstance로 받는게 아니기때문에 애니메이션은 보이지 않는다고 생각한다.... ex) 따로 언리얼엔진문서에 설명을 안해주기에 여러번 돌려본결과로 말해본다.)
그래서 함수를 호출할때 Server->Multicast로 호출은 그냥 진짜 쉽게 Server에서 Multicast함수를 호출하면 된다.
.h
UFUNCTION(Server, Reliable, WithValidation)
void Server_TestFunction(uint8 DirectionIndex);
UFUNCTION(NetMulticast, Reliable, WithValidation)
void Multicast_TestFunction(uint8 DirectionIndex);
.cpp
void ACharacterBase::Server_TestFunction_Implementation(uint8 DirectionIndex)
{
Multicast_TestFunction(DirectionIndex);
}
bool ACharacterBase::Server_TestFunction_Validate(uint8 DirectionIndex)
{
return true;
}
void ACharacterBase::Multicast_TestFunction_Implementation(uint8 DirectionIndex)
{
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (!AnimInstance || !RollMt) return;
AnimValues.bRoll = true;
const char* SectionList[] = { "Forward", "Left", "Right", "Back_L", "Back_R", "Dodge" };
AnimInstance->Montage_Play(RollMt);
AnimInstance->Montage_JumpToSection(FName(SectionList[DirectionIndex]), RollMt);
}
bool ACharacterBase::Multicast_TestFunction_Validate(uint8 DirectionIndex)
{
return true;
}
'Unreal Engine 4 프로그래밍 c++ > Online Multiplayer' 카테고리의 다른 글
Unreal Multiplayer cast spell c++ 초안 (0) | 2023.03.30 |
---|---|
Unreal Multiplayer 애매모호성 1 (0) | 2023.03.25 |
Unreal ReplicatedUsing c++ 기초2 (0) | 2023.03.15 |
Unreal Replicated c++ 기초1 (2) | 2023.03.11 |
Unreal RPC c++ 기초1 (0) | 2023.02.14 |
- Total
- Today
- Yesterday
- RPC
- ActorComponent
- 1993
- directx3d
- 언리얼#게임
- 포레스트 검프
- 게임프로그래밍
- 언리얼#프로그래밍#c++#포트폴리오준비#블루프린트->c++전환
- 게임
- Direct12
- Multiplayer
- 포트폴리오
- LockonSystem
- ReplicatedUsing
- Multipalyer
- DirectX12
- 언리얼엔진#FPS
- c++
- html5
- 영화리뷰
- 시애틀의 잠 못 이루는 밤
- UnReal
- 4.27
- DirectX
- 언리얼#c++#Interface
- 언리얼
- Direct3D
- Replicated
- 언리얼#c++#기능
- 프로그래밍
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |