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

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

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 player
	if (GetPawn() != NULL)
	{
		// Only hide the pawn if in cinematic mode and we want to
		if (bCinematicMode && bHidePlayer)
		{
			GetPawn()->SetActorHiddenInGame(true);
		}
		// Always safe to show the pawn when not in cinematic mode
		else if (!bCinematicMode)
		{
			GetPawn()->SetActorHiddenInGame(false);
		}
	}

	// Let the input system know about cinematic mode
	SetCinematicMode(bCinematicMode, bAffectsMovement, bAffectsTurning);

	// Replicate to the client
	ClientSetCinematicMode(bCinematicMode, bAffectsMovement, bAffectsTurning, bAffectsHUD);
}



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值