Warning: Declaration of action_plugin_linebreak::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php on line 41

Warning: Declaration of action_plugin_markdownextra::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/markdownextra/action.php on line 16

Warning: Declaration of action_plugin_syntaxhighlighter3_action::register(Doku_Event_Handler &$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/syntaxhighlighter3/action/action.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php:0) in /home/stepism/www/ue4/wiki/inc/auth.php on line 430

Warning: Declaration of syntax_plugin_linebreak::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/syntax.php on line 52

Warning: Declaration of syntax_plugin_linebreak::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/syntax.php on line 74

Warning: Declaration of syntax_plugin_syntaxhighlighter3_syntax::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /home/stepism/www/ue4/wiki/lib/plugins/syntaxhighlighter3/syntax/syntax.php on line 53

Warning: Declaration of syntax_plugin_syntaxhighlighter3_syntax::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /home/stepism/www/ue4/wiki/lib/plugins/syntaxhighlighter3/syntax/syntax.php on line 82

Warning: Cannot modify header information - headers already sent by (output started at /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php:0) in /home/stepism/www/ue4/wiki/inc/actions.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php:0) in /home/stepism/www/ue4/wiki/lib/tpl/dokuwiki/main.php on line 12
割り当てたキーに処理を割り当てる(4.7.5) [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:ue4:input:002

割り当てたキーに処理を割り当てる(4.7.5)

キーの割り当てについて(4.7.5)で割り当てたキーに対して、処理を割り当ててみます。
ここでは仮にMyPawnクラスを用意してログを出力するだけの物を実装します。

ブループリントで対応する

MyPawnブループリントの中身はこんな感じになっています。

赤いノードが入力結果を受け取りイベントを発行し、各種関数を呼び出しています。

押しっぱなし判定はこんな感じ。

C++で対応する

まず、割り当てる関数を準備しておきます。

 
void AMyPawn::MoveX(float AxisValue) 
{ 
    UE_LOG(LogTemp, Log, TEXT("AMyPawn::MoveX() called")); 
} 

void AMyPawn::MoveY(float AxisValue) 
{ 
    UE_LOG(LogTemp, Log, TEXT("AMyPawn::MoveY called")); 
} 

void AMyPawn::StartScaling() 
{ 
    UE_LOG(LogTemp, Log, TEXT("AMyPawn::StartScaling called")); 
} 

void AMyPawn::StopScaling() 
{ 
    UE_LOG(LogTemp, Log, TEXT("AMyPawn::StopScaling called")); 
} 

次に、ポーンクラスのSetupPlayerInputComponent等で、アクション(関数)を割り当てます。

 
void AMyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent) 
{ 
    Super::SetupPlayerInputComponent(InputComponent); 
	 
    // 拡縮 キーアクション割り当て 
    InputComponent->BindAction("Scale", IE_Pressed, this, &AMyPawn::StartScaling);	// 押した時 
    InputComponent->BindAction("Scale", IE_Released, this, &AMyPawn::StopScaling);	// 離した時 

    // 移動キーアクションの割り当て 
    InputComponent->BindAxis("MoveX", this, &AMyPawn::MoveX); 
    InputComponent->BindAxis("MoveY", this, &AMyPawn::MoveY); 
} 

これで、割り当てた関数が呼ばれる様になります。

既知の問題

  • BindActionに E_Repeat を指定すると関数が呼ばれない。

押しっぱなし判定について

  • ボタンアクションにE_Repeatが使えないので、フラグを用いて代替え案。

 
bIsDown = true; 

void AMyPawn::Tick( float DeltaTime ) 
{ 
    Super::Tick( DeltaTime ); 

    // 押しっぱなし判定 
    if (bIsDown) 
    { 
    	UE_LOG(LogTemp, Log, TEXT("bIsDown")); 
    } 
} 

void AMyPawn::StartScaling() 
{ 
    bIsDown = true; 
} 

void AMyPawn::StopScaling() 
{ 
    bIsDown = false; 
} 

wiki/ue4/input/002.txt · 最終更新: 2015/04/22 06:54 (外部編集)