RPG46.制作boss的受击和boss的死亡
1。创建boss的受击反应
从shared的abilitysystem内创建hitreact的子类
如下图设置为玩家在攻击boss后无法中断boss当前的行为,boss也不会在受击后转向玩家
然后设置受击材质
以上是受击
2.创建boss的死亡
打开shared文件夹找到enemydeathbase
复制子类蓝图
创建好对应的蒙太奇
3。接下来为了解决boss在死亡之后,血量条不会消失的情况
打开EnemyUiComponent.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "PawnUIComponent.h"#include "EnemyUIComponent.generated.h"class UWarriorWidgetBase;/*** */
UCLASS()
class ARPG_GRIVITY_API UEnemyUIComponent : public UPawnUIComponent
{GENERATED_BODY()public:UFUNCTION(BlueprintCallable)void RegisterEnemyDrawnWidget(UWarriorWidgetBase* InWidgetToRegister);UFUNCTION(BlueprintCallable)void RemoveEnemyDrawnWidgetIsAny();private:TArray<UWarriorWidgetBase*> EnemyDrawnWidgets;};
// Fill out your copyright notice in the Description page of Project Settings.#include "Components/UI/EnemyUIComponent.h"#include "Widgets/WarriorWidgetBase.h"void UEnemyUIComponent::RegisterEnemyDrawnWidget(UWarriorWidgetBase* InWidgetToRegister)
{EnemyDrawnWidgets.Add(InWidgetToRegister);
}void UEnemyUIComponent::RemoveEnemyDrawnWidgetIsAny()
{if (EnemyDrawnWidgets.IsEmpty()){return;}for (UWarriorWidgetBase* DrawWidget : EnemyDrawnWidgets){if (DrawWidget){DrawWidget->RemoveFromParent();}}}
启动项目
打开DrawBossBar_Base,把属于boss的ui加载进去
打开EnemyDeath_Base,在死亡时移除他们