์๋ ์์ธ์ ๋น๊ฒ์ด์ธ ํ๋๋
c++ ํ๋ก์ ํธ ์์ํ ์ด๋ณด์ ๋๋ค
์ ๋ ํ๋ค์ด ํ ํ๋ฆฟ์ c++๋ก ๋ง๋ค์์ต๋๋ค
์ ๋ ์ํ ํจํด(?)์ฒ๋ผ ์ก์ ์ ๋ฐ์ธ๋ฉํ๋ ค๊ณ ํ์ต๋๋ค
์๋ฅผ ๋ค์ด ์ผ์ชฝ ๋ง์ฐ์ค๋ฅผ ๋๋ฅด๋ฉด ์บ๋ฆญํฐ๊ฐ ์ปค์์๋์ชฝ์ผ๋ก ์ด๋ํ์ง๋ง Q ํค๋ฅผ ๋๋ฅด๋ฉด ๋ง์ฐ์ค ์ผ์ชฝ ๋ฒํผ์ด ์คํฌ ์คํ ๋ฒํผ์ผ๋ก ๋ฐ๋๋๊ฒ๋๋ค
๊ทธ๋์ ์๋ณธ ์ฝ๋๋ฅผ:
EnhancedInputComponent->BindAction(MouseLeftClickAction, ETriggerEvent::Started, this, &AMyPlayerController::OnInputStarted);
EnhancedInputComponent->BindAction(MouseLeftClickAction, ETriggerEvent::Triggered, this, &AMyPlayerController::OnMouseLeftButtonTriggered);
EnhancedInputComponent->BindAction(MouseLeftClickAction, ETriggerEvent::Completed, this, &AMyPlayerController::OnMouseLeftButtonReleased);
EnhancedInputComponent->BindAction(MouseLeftClickAction, ETriggerEvent::Canceled, this, &AMyPlayerController::OnMouseLeftButtonReleased);
์ด๋ฐ์์ผ๋ก ๋ณ๊ฒฝํด์ ์ฌ์ฉํ๋ ค๊ณ ย ์๋ํ์ต๋๋ค:
voidย AMyPlayerController::BindInputAction(UInputAction* InputAction,ย AMyPlayerController* BindInputActionHandler)
{
UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(InputComponent);
EnhancedInputComponent->BindAction(InputAction, ETriggerEvent::Started, this, &BindInputActionHandler::OnStarted);
EnhancedInputComponent->BindAction(InputAction, ETriggerEvent::Triggered, this, &BindInputActionHandler::OnTriggered);
EnhancedInputComponent->BindAction(InputAction, ETriggerEvent::Completed, this, &BindInputActionHandler::OnCompleted);
EnhancedInputComponent->BindAction(InputAction, ETriggerEvent::Canceled, this, &BindInputActionHandler::OnCanceled);
}
๋ฌธ์ ๋ ๋ง์ง๋ง ์ธ์ย &BindInputActionHandler::OnStarted ์ด ๋ถ๋ถ์ธ๋ฐ ๋ณด๋๊นย AMyPlayerControllerย ๋ฐ์ ๋ชป ๋๊ฒจ์ฃผ๋๋ผ๊ณ ์.
๊ทธ๋ผ ํจ์๋ฅผ ์ ๋ถย AMyPlayerController์ ์์ฑํด์ผ ๋๋์? ๋ฏธ์น๊ฒ์ด์ฉ
BindInputActionHandler ํด๋์ค๋ฅผย AMyPlayerController ์์๋ฐ๊ฒ ํ๋๋ฐ๋ ์๋์ ์ฃฝ๊ฒ์ด์ฉ
์ด๋ขํ์ฃ ์ด๋ขํ์ฃ
this๋ฅผ ๋ฐ์ธ๋์ธํ์ก์ ํธ๋ค๋ฌ ํฌ์ธํฐ๋ก ๋ฐ๊พธ์ผ - dc App
์ ํธ๋ค๋ฌ๊ฐ ํด๋์ค๊ฐ ์๋๊ณ ๊ฑ ํฌ์ธํฐ๊ตฌ๋ ์ ๋ฌ๋ฉด ๋น์ฐํ ์๋์ง - dc App
์ง๊ธ ์ฝ๋๋ฅผ ๋ณด๋ฉด, this๋ ์ด ํจ์ ๋์ํ๋ AMyPlayerController๊ณ , ๋ฌถ์ผ๋ ค๋ ํจ์๋ &bindinputActionHandler๋ผ๊ณ ๋์ด ์๋๋ฐ, ์ ์ด์ BindInputActionHandler๊ฐ AMyPlayerController์ ๊ฐ์ฒด๋ผ์ ๊ทธ๋ฐ ์์ผ๋ก ๋ชป๋๊ธฐ์ง ์์? ํ๋ ค๋ ํ๋์ด (~~, BindInputActionHandler,&AMyPlayerController::OnStarted); ์ด๊ฑฐ๋ ๊ฐ์ง ์์?
BindInputActionHandler๋ ํฌ์ธํฐ์ธ๋ฐ BindInputActionHandler:: ๋ผ๋ ๋์์์ฒด๊ฐ ๋ถ๊ฐ๋ฅํ์ง์๋์
๊ทธ๋ฅ ํจ์ ์ญ ๋ฃ์ผ์๊ณ ์ปจํธ๋กค๋ฌ์์ Q๋ฅผ ๋๋ ์๋์ ๋ํ ๋ถ๊ธฐ๋ฅผ ๋ฃ์ผ์ธ์ ํจ์ํ ํ๋ฆฟ์ฐ์๋๊ฑธ ์ถ์ฒ๋๋ฆฝ๋๋ค