SlideShare a Scribd company logo
프로그래머를 괴롭히는 UE4의 함정들
“이게 대체 왜 안돼!?”
넥슨지티 초심팀
이현승
목차
1. 요약
2. 대상
3. 에디터
4. 블루프린트
5. C++
6. 리플리케이션
요약
• 문서에 없는 이상하고 신비로운 것들
• 절반은 리플리케이션
대상
• UE4를 처음 접하는 분들을 위한 튜토리얼이 아닙니다.
• 기본 문서나 튜토리얼들을 통해서 배울 수 있는 얘기들은 안합니다.
• 하지만 모르면 이해 못할 내용들이 있습니다.
• UE4를 좀 해보신 분들은 (아마도?)다 아시는 내용일 겁니다.
• “기본지식 불필요”라더니?
출처 : http://musicairman.deviantart.com/art/The-Revelation-
91619763
허가 : http://creativecommons.org/licenses/by-sa/3.0/
원작자 : musicairman(http://musicairman.deviantart.com/)
프로그래머를 괴롭히는 ue4의 함정들
에디터
C++코드 수정 후 컴파일 했는데 적용이 안돼요
C++코드 수정 후 컴파일 했는데 적용이 안돼요
가끔 컴파일 버튼이 사라집니다.
핫리로드가 안되는 상태.
에디터를 다시 실행하세요.
저장이 안돼요
저장이 안돼요
같은 프로젝트의 에디터를 두번 열었습니다.
하나 닫으세요.
블루프린트
상속해서 뭔가를 만들 때
DEFAULT값이 뭔짓을 해도
안바꿔지는 버그있음
상속 부모를 바꾸고 싶을 때
블루프린트를 열고 파일 메뉴에 보면 있음
Delay
Delay
Delay
Delay
Delay
TagMarker
TagMarker
Delay
TagMarker
TagMarker
Delay
TagMarker TagMarker
C++
생성자
UObject:: UObject (const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) {}
쓰면 안되는 것
• ActorSpawn, NewObject<T> 등을 생성자에서 쓰면 안된다.
• BeginPlay()에서 쓰자.
• 생성자에서 쓰면 되는 것 처럼 보인다. 에디터에서 실행할 때는.
• 빌드하면 됐다 안됐다 한다.
• GEngine은 AccessViolation
써야 하는 것
• Subobject Initialize는 ObjectInitializer가 있어야만 가능
ABaseCharacter::ABaseCharacter(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) {
ThirdView = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("ThirdView"));
ThirdViewSpringArm = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("ThirdViewSpringArm"));
}
문서를 보다가…
• PICP가 보이면 의심
• 문서가 낡았다는 첫 번째 증거
UMyObject::UMyObject(const class FPostConstructInitializeProperties& PCIP): Super(PCIP)
{
}
UMyObject::UMyObject(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer)
{
}
낡은 문서의 증거
이전 현재
FPostConstructInitializeProperties& PCIP
FObjectInitializer& ObjectInitializer
OVERRIDE override
BIND_AXIS()
InputComponenet->BindAxis()
TSubObjectPtr<AActor> my_actor; AActor* my_actor;
언리얼매크로
사례1
사례1
• 정체 불명
사례1
• 문서에선 확인 불가.
• 포럼 사용 예시에선 설명 없이 그냥 잘 씀.
• 문제는 빌드 에러 메시지가 여기가 문제라고 알려주지도 않음.
사례2
사례2
사례3
• HttpRequest의 Callback으로 쓰이는 인터페이스
사례3
• UFUNCTION() 떼면 잘 됨.
• FHttpRequestPtr, FHttpResponsePtr랑 붙어있으면 안되는 거 같음.
C++에서 블루프린트 불러오기
• LoadClass 사용금지
• 낡은 문서라는 두 번째 증거
• static ConstructorHelpers::FObjectFinder<UClass> 를 사용
• static ConstructorHelpers::FClassFinder<UClass> 아님
• BP에는 사실
• Object인 BP가 있고
• Class인 BP가 있다
C++에서 블루프린트 불러오기
• _C로 구분
static ConstructorHelpers::FObjectFinder<UParticleSystem>
bloodParticle(TEXT("ParticleSystem'/Game/Impacts/Particles/P_ImpactBlood.P_ImpactBlood'"));
if (bloodParticle.Object){
Blood = bloodParticle.Object;
}
static ConstructorHelpers::FObjectFinder<UClass>
WidgetClassLoader(TEXT("WidgetBlueprint'/Game/Custom/Widget/InfoWidget.InfoWidget_C'"));
if (WidgetClassLoader.Object){
WidgetClass = WidgetClassLoader.Object;
Widget = CreateWidget<UUserWidget>(GetWorld(), WidgetClass);
}
TSubclassOf<UUserWidget> WidgetClass;
UUserWidget* Widget;
UParticleSystem* Blood;
Delegate
• UObject는 다중상속이 안됩니다.
• 하려고 들면 역시나 정체불명의 에러가 뜸
• Delegate가 필요할 땐?
• https://docs.unrealengine.com/latest/INT/Programming/Unreal
Architecture/Delegates/index.html
• Delegate 매크로가 있습니다.
DECLARE_DELEGATE_OneParam(FMyDelegate, Fstring);
FMyDelegate delegate;
delegate.Bind(...)
delegate.ExecuteIfBound(TEXT(“param”));
리플리케이션
https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Actors/index.html
TMap<>은 리플리케이션 안됨
https://forums.unrealengine.com/showthread.php?13133-TMap-lt-gt-Replication-
exposing-to-Unreal-reflection
• 5년전에 한다고 해놓고 아직도 안되는걸 보면 그냥 안됨
• 리스트 두개를 쓰는 등 꼼수로 회피
Property Replication을 쓸 때 조심할 점
• A = 0
• 함수 B()에서, Authority에서 A=1
• C()를 부름
• Client Replication Function D()를 부름
• D() 내부에서 A는 얼마?
Property Replication을 쓸 때 조심할 점
• 답 : 0
• 리플리케이션은 틱의 마지막에 일어난다.
Function Replication
•RPC라고도 부름
•BP에서는 사실 Function에 해당하지도 않음 -> Custom Event
•리플리케이트 되지 않음
•서버에서 실행
•멀티캐스트
•소유 클라이언트에서 실행
RPC
•https://docs.unrealengine.com/latest/INT/Gameplay/Networking/A
ctors/RPCs/index.html
•Actor 에서 호출되어야 합니다.
•Actor 는 반드시 replicated 여야 합니다.
•서버에서 호출되고 클라이언트에서 실행되는 RPC 의 경우, 해당 Actor 를 실
제 소유하고 있는 클라이언트에서만 함수가 실행됩니다.
•클라이언트에서 호출되고 서버에서 실행되는 RPC 의 경우, 클라이언트는
RPC 가 호출되는 Actor 를 소유해야 합니다.
RPC
•Multicast RPC 는 예외입니다:
•서버에서 호출되는 경우, 서버에서는 로컬에서 실행될 뿐만 아니라 현재 연결된 모
든 클라이언트에서도 실행됩니다.
•클라이언트에서 호출되는 경우, 로컬에서만 실행되며, 서버에서는 실행되지 않습니
다.
•현재 멀티캐스트 이벤트에 대해 단순한 스로틀 조절 메카니즘이 있습니다. 멀티캐
스트 함수는 주어진 액터의 네트워크 업데이트 기간동안 두 번 이상 리플리케이트
되지 않습니다. 장기적으로 크로스 채널 트래픽 관리 및 스로틀 조절 지원을 개선시
킬 계획입니다.
RPC
리플리케이트 되지 않음
• 사실 이놈이 리플리케이션 지옥의 주범
리플리케이트 되지 않음
어디서
실행되는가?
서버에서 실행
• 상자는 과연 열릴 것인가
서버에서 실행
• 안열림
• “서버에 리플리케이트됨(소유 클라이언트인 경우)”
• 클라이언트 쪽 상자는 상자를 소유한(컨트롤러가 존재하는) 클라이언트가
없다. open() 호출이 안됨
서버에서 실행
멀티캐스트
멀티캐스트
• 전체에서 실행이 될까?
• in PlayerController
멀티캐스트
• 안된다
• “모두에 리플리케이트됨(서버인 경우)”
• 키보드 입력은 클라이언트라서 리플리케이트 되지 않고
클라이언트에서 실행됨
멀티캐스트
멀티캐스트
• 이러면 되나?
• in PlayerController
멀티캐스트
• 안된다. PlayerController에서는 서버랑 자기 클라이언트만
멀티캐스트 됨.
• PlayerCharacter에서는 전체 멀티캐스트 됨
?
소유 클라이언트에서 실행
소유 클라이언트에서 실행
• Event를 호출할 때 Target을 소유한 클라이언트가 있는가?
• AI는 소유한 클라이언트가 존재하지 않음. 서버가 소유. 서버에서
호출
RPC 정리
• Player Controller
client
server
server & owning
client only
RPC 정리
• Player Character
client
server
server & all
clients
RPC 정리
• Chest(or other actors)
• 키보드 입력을 직접 받을 수 없다.(PlayerController로부터 전파되는거라)
RPC 정리
• Chest(or other actors)
client
client
RPC 정리 - 정답
• 플레이어 컨트롤러는 클라이언트에서 서버로, 상자는 서버에서
멀티캐스트로
client
server
server
multicast
PC
PC PC
PC
PC
PC PC
PC
서버에 리플리케이트됨(소유 클라이언트인 경우)
PC
PC PC
PC
서버에 리플리케이트됨(소유 클라이언트인 경우)
PC
PC PC
PC
실행 안됨
서버에 리플리케이트됨(소유 클라이언트인 경우)
PC
PC PC
PC
모두에 리플리케이트됨(서버인 경우)
PC
PC PC
PC
모두에 리플리케이트됨(서버인 경우)
PC
PC PC
PC
모두에 리플리케이트됨(서버인 경우)
PC
PC PC
PC
모두에 리플리케이트됨(서버인 경우)
PC
PC PC
PC
모두에 리플리케이트됨(서버인 경우)
PC
PC PC
PC
소유중인 클라이언트에서 실행
PC
PC PC
PC
소유중인 클라이언트에서 실행
PC
PC PC
PC
소유중인 클라이언트에서 실행
PC
PC PC
PC
AI
문제는,
프로그래머를 괴롭히는 ue4의 함정들
프로그래머를 괴롭히는 ue4의 함정들
프로그래머를 괴롭히는 ue4의 함정들
사례 1 : 캐릭터가 이동할 때 부르르 떨린다
•싱글에선 괜찮다.
•서버에 붙으면 그런다.
•ActorReplication을 꺼주면 또 괜찮다.(이동이 서로 반영되지 않는 문제가
생기지만)
•왜지?!
사례 1 : 캐릭터가 이동할 때 부르르 떨린다
•캐릭터 이동속도 변경 때문
•ACharacter::CharacterMovementComponent 에 다른 이동상태 변화는 다 있는
데 Run은 없다.
• Character->CharacterMovementComponent->SetMaxWalkSpeed(int);
• CharacterMovement는 AddMovementInput()로 이동을 리플리케이션까지 해
주는 녀석
사례 1 : 캐릭터가 이동할 때 부르르 떨린다
• Character->CharacterMovementComponent->SetMaxWalkSpeed(int); 는
리플리케이션 안해줌.
• 서버랑 클라랑 캐릭터 이동속도가 달라서.
• ActorReplication되면서 둘 다 번갈아가면서 적용하려다 보니 부들부들.
사례 2 : MovementComponent 없는 Pawn의 이동
사례 2 : MovementComponent 없는 Pawn의 이동
• 웃기는 상황
• 안움직인다.
• 두명이상 멀티(dedicated server)로 실행해보면
• 내가 움직이는게 내 화면에선 안보이고
• 남의 화면에선 보인다.
사례 2 : MovementComponent 없는 Pawn의 이동
• 액터 Replication은 분명히 켜져 있는데?
• (그러니까 남들에게 보이겠지?)
사례 2 : MovementComponent 없는 Pawn의 이동
Q&A
감사합니다.

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

프로그래머를 괴롭히는 ue4의 함정들