언리얼 c++프로그래밍 - Controller의 Possess()함수에 대해
GetWorld()->GetFirstPlayerController()->Possess(this); //현재 pawn으로 빙의. this는 pawn을 상속받은 클래스
Possess는 소유하다, 지니다는 뜻으로 Controller를 지니게되는 Pawn을 정해준다.
APawn*을 인자로 받는다.(APawn을 상속받은 하위 클래스 포함)
인자로 들어온 pawn으로 Controller와 카메라 시점을 이동할 수 있다.
이것에 대해 아래와 같은 연관되게 되는 함수가 있다.
//현재 Pawn에 대해
//SetupPlayerInputComponent(GetWorld()->GetFirstPlayerController()->InputComponent); //키맵핑 하는 함수
//Possess()함수를 실행하면서 SetupPlayerInputComponent 함수도 같이 실행됨. 그래서 따로 함수 호출을 안해도 된다.
//과거 Pawn에 대해
//GetWorld()->GetFirstPlayerController()->UnPossess();
//이전의 pawn에 있던 Controller가 nullptr이 된다.
위의 함수들은 Possess할 때 자동으로 불리우며
과거와의 연을 끊고 새로운 연을 잇는다고 생각하면 편하다.
정리
Possess()함수를 호출하면
이전에 Controller가 빙의해있던 pawn은 UnPossess()가 실행 되면서 Controller가 nullptr이 된다.
현재 이동할 pawn이 Controller를 가지게 되고
자동으로 SetupPlayerInputComponent(UInputComponent*)함수를 호출한다.
SetupPlayerInputComponent()함수에서 키맵핑 하는 법은 다음 글에 이어서 하겠다.
'공부 > Unreal4' 카테고리의 다른 글
키맵핑(바인딩) 삭제 - PlayerInput 비우기, InputComponent 비우기 (0) | 2017.04.19 |
---|---|
언리얼4 c++프로그래밍 - 키맵핑(바인딩) 설정 (0) | 2017.04.17 |
FindComponentByClass 의 위험성 (1) | 2017.04.14 |
언리얼 c++에서 스폰된 액터 클래스 명으로 찾기 (0) | 2017.04.05 |
마이그레이션 중.. #include<Windows.h>문제와 wchar_t to std::string 한글 문제 (0) | 2017.04.05 |