RPG59.玩家拾取物品三:可拾取物品的提示UI

1。以WarriorWidgetBase作为父类,创建一个子类的userwidget

2.布局为

两个值都为120

3。然后我们需要想办法,在合适的位置,用bool来控制此控件的显示与隐藏。

情况为:当玩家触发与可拾取物体的重叠时,我们将广播一个bool值用来显示可拾取提示

打开PlayerUiComponent.h

复制代码
//控制显示拾取物品的提示
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnStoneInteractedDelegate, bool, bShouldDisplayInputKey);

//控制显示物体
	UPROPERTY(BlueprintCallable,BlueprintAssignable)
	FOnStoneInteractedDelegate OnStoneInteracted;

我们还需要获取player的uicomponent,打开WarriorPlayerGameplayAbility.h

复制代码
//获取玩家UI组件
	UFUNCTION(BlueprintPure, Category = "XMB|Ability")
	UPlayerUIComponent* GetPlayerUIComponentFromActorInfo();

UPlayerUIComponent* UWarriorPlayerGameplayAbility::GetPlayerUIComponentFromActorInfo()
{
	return GetPlayerCharacterFromActorInfo()->GetPlayerUIComponent();
}

然后打开PlayerGA_PickUpStones,处理广播事件,这样子我们就将bool广播出去了

复制代码
void UPlayerGA_PickUpStones::ActivateAbility(const FGameplayAbilitySpecHandle Handle,const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo,const FGameplayEventData* TriggerEventData)
{
	//显示可拾取提示
	GetPlayerUIComponentFromActorInfo()->OnStoneInteracted.Broadcast(true);
	
	Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);
}

void UPlayerGA_PickUpStones::EndAbility(const FGameplayAbilitySpecHandle Handle,const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo,bool bReplicateEndAbility, bool bWasCancelled)
{
	GetPlayerUIComponentFromActorInfo()->OnStoneInteracted.Broadcast(false);
	
	Super::EndAbility(Handle, ActorInfo, ActivationInfo, bReplicateEndAbility, bWasCancelled);
}

4。接下来处理监听

启动项目,打开Overlay

我们需要获取当前用来拾取物品的键位

相关推荐
远离UE412 小时前
UE5 Niagara LightWeight Emitter
ue5
StarTechnology1 天前
UE5云渲染管理平台-支持私有化部署Linux-Windows国产化适配
ue5·webui·webbrowser
码匠许师傅1 天前
【设计模式精讲】25.状态模式(State)
c++·ui·设计模式·状态模式·uml
平行云1 天前
实时云渲染信创架构解析:从GPU池化到全栈适配的技术演进
linux·unity·docker·ue5·webgl·数字孪生·实时云渲染
插件开发2 天前
Illustrator 插件开发:链接文件存在检查的原理与实战
ui·illustrator
xy34532 天前
axure9.0 如何打造一个计时器(简单版)
前端·ui·html·axure·原型·产品设计
图扑软件2 天前
下篇・换墨|主题/多语言/移动端,一套组件全覆盖
前端·javascript·ui·性能优化·数据可视化
远离UE43 天前
UE5 高性能 实时 玻璃破碎系统
ue5
远离UE43 天前
UE5 多线程 与 异步 并行
ue5
object not found4 天前
从 Page Design 到 System Design:我对 UI/UX 的一次认知变化
ui·ux