坑爹的SetCinematicMode--如何屏蔽用户输入的移动指令

来源:互联网 发布:php用iis和apache 编辑:程序博客网 时间:2024/05/21 08:38

游戏里,当角色在放大招,处于施放技能的状态中时,希望屏蔽掉用户输入中那些移动指令。否则角色的技能效果会因为角色的移动变形,或者角色在放大招时,就希望此时万千的指令皆空,惟有沉浸于此此时的大招。

UE已经提供了屏蔽用户输入的接口函数。

定义和实现都在PlayerController中:

void APlayerController::SetCinematicMode( bool bInCinematicMode, bool bAffectsMovement, bool bAffectsTurning);

void APlayerController::SetCinematicMode(bool bInCinematicMode, bool bHidePlayer, bool bAffectsHUD, bool bAffectsMovement, bool bAffectsTurning);


在Blueprint里可以用SetCinematicMode节点,是SetCinematicMode(bool bInCinematicMode, bool bHidePlayer, bool bAffectsHUD, bool bAffectsMovement, bool bAffectsTurning)这个函数。 而且,只能在Level Blueprint里使用。

SetCinematicMode里的几个参数如何设置,还真折腾浪费一些时间。以屏蔽Movement为例。

屏蔽Movement: bInCinematicMode = true, 且bAffectsMovement = true;

启用Movement::bInCinematicMode = false, 且bAffectsMovement = true。


这种搭配真奇葩。官方文档对这几个参数的解释也不清楚。 看源代码吧!

void APlayerController::SetCinematicMode( bool bInCinematicMode, bool bAffectsMovement, bool bAffectsTurning){            ///* 由此可知,bAffectsMovement必须保持为True,才有可能设置SetIgnoreMoveInput(...)。 搭配使用bCinemaDisableInputMove,才能有效地IgnoreMoveInput。 */if ( bAffectsMovement && (bInCinematicMode != bCinemaDisableInputMove) ){SetIgnoreMoveInput(bInCinematicMode);bCinemaDisableInputMove = bInCinematicMode;}if ( bAffectsTurning && (bInCinematicMode != bCinemaDisableInputLook) ){SetIgnoreLookInput(bInCinematicMode);bCinemaDisableInputLook = bInCinematicMode;}}


void APlayerController::SetCinematicMode(bool bInCinematicMode, bool bHidePlayer, bool bAffectsHUD, bool bAffectsMovement, bool bAffectsTurning){bCinematicMode = bInCinematicMode;// If we have a pawn we need to determine if we should show/hide the playerif (GetPawn() != NULL){// Only hide the pawn if in cinematic mode and we want toif (bCinematicMode && bHidePlayer){GetPawn()->SetActorHiddenInGame(true);}// Always safe to show the pawn when not in cinematic modeelse if (!bCinematicMode){GetPawn()->SetActorHiddenInGame(false);}}// Let the input system know about cinematic modeSetCinematicMode(bCinematicMode, bAffectsMovement, bAffectsTurning);// Replicate to the clientClientSetCinematicMode(bCinematicMode, bAffectsMovement, bAffectsTurning, bAffectsHUD);}



0 0
原创粉丝点击