当前位置: 首页 > news >正文

重庆网站开发设计公司电话推广软文模板

重庆网站开发设计公司电话,推广软文模板,个人做地方网站,淅川网站建设前面几节文章介绍了如何在角色身上添加AbilitySystemComponent和AttributeSet。并且还实现了给AttributeSet添加自定义属性。接下来,实现一下如何去修改角色身上的Attribute的值。 实现拾取药瓶回血功能 首先创建一个继承于Actor的c类,actor是可以放置到…

前面几节文章介绍了如何在角色身上添加AbilitySystemComponent和AttributeSet。并且还实现了给AttributeSet添加自定义属性。接下来,实现一下如何去修改角色身上的Attribute的值。

实现拾取药瓶回血功能

在这里插入图片描述
首先创建一个继承于Actor的c++类,actor是可以放置到场景中的基类。

	UPROPERTY(VisibleAnywhere)TObjectPtr<UStaticMeshComponent> Mesh;

创建一个静态模型组件,用来显示当前可拾取物的模型。

	UPROPERTY(VisibleAnywhere)TObjectPtr<USphereComponent> Sphere;

创建一个碰撞体球,用于检测和主角的碰撞来触发回调。

	Mesh = CreateDefaultSubobject<UStaticMeshComponent>("Mesh");SetRootComponent(Mesh);Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");Sphere->SetupAttachment(GetRootComponent());

然后初始化中,创建对象,并将Mesh设置为根节点,并将球碰撞体挂在Mesh下面。

UFUNCTION()
virtual void OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);UFUNCTION()
virtual void EndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

创建两个回调,用于碰撞触发的开始和结束。

	Sphere->OnComponentBeginOverlap.AddDynamic(this, &AEffectActorBase::OnOverlap);Sphere->OnComponentEndOverlap.AddDynamic(this, &AEffectActorBase::EndOverlap);

绑定到球体碰撞事件上,如果球体触发了碰撞,则会调用这两个函数。

void AEffectActorBase::OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{//TODO: 为了测试数值修改功能,启用了常量转变量功能。if(IAbilitySystemInterface* ASCInterface = Cast<IAbilitySystemInterface>(OtherActor)){//根据类从ASC里面获取到对应的AS实例const UAttributeSetBase* AttributeSet = Cast<UAttributeSetBase>(ASCInterface->GetAbilitySystemComponent()->GetAttributeSet(UAttributeSetBase::StaticClass()));UAttributeSetBase* MutableAttributeSet = const_cast<UAttributeSetBase*>(AttributeSet); //将常量转为变量MutableAttributeSet->SetHealth(AttributeSet->GetHealth() + 25.f);Destroy(); // 销毁自身}
}

接着在碰撞触发的时候,从接口获取到AttributeSet,然后设置数值增长。
在这里插入图片描述
接下来在UE里面创建一个蓝图,基于EffectActorBase。
在这里插入图片描述
左侧会发现我们在代码中添加的Mesh和Sphere。
在这里插入图片描述
添加模型网格体,然后调整球的大小。
在这里插入图片描述
运行场景,输入showdebug abilitysystem
在这里插入图片描述
如果值修改,那证明功能实现。

EffectActorBase.h

// 版权归暮志未晚所有。#pragma once#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "EffectActorBase.generated.h"class USphereComponent;
class UStaticMeshComponent;UCLASS()
class AURA_API AEffectActorBase : public AActor
{GENERATED_BODY()public:	AEffectActorBase();UFUNCTION()virtual void OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);UFUNCTION()virtual void EndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);protected:// 游戏开始或生成对象时回调virtual void BeginPlay() override;private:UPROPERTY(VisibleAnywhere)TObjectPtr<USphereComponent> Sphere;UPROPERTY(VisibleAnywhere)TObjectPtr<UStaticMeshComponent> Mesh;
};

EffectActorBase.app

// 版权归暮志未晚所有。#include "Actor/EffectActorBase.h"#include "AbilitySystemComponent.h"
#include "AbilitySystemInterface.h"
#include "AbilitySystem/AttributeSetBase.h"
#include "Components/SphereComponent.h"AEffectActorBase::AEffectActorBase()
{// 设置当前对象是否每帧调用Tick()PrimaryActorTick.bCanEverTick = false;Mesh = CreateDefaultSubobject<UStaticMeshComponent>("Mesh");SetRootComponent(Mesh);Sphere = CreateDefaultSubobject<USphereComponent>("Sphere");Sphere->SetupAttachment(GetRootComponent());
}void AEffectActorBase::OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{//TODO: 为了测试数值修改功能,启用了常量转变量功能。if(IAbilitySystemInterface* ASCInterface = Cast<IAbilitySystemInterface>(OtherActor)){//根据类从ASC里面获取到对应的AS实例const UAttributeSetBase* AttributeSet = Cast<UAttributeSetBase>(ASCInterface->GetAbilitySystemComponent()->GetAttributeSet(UAttributeSetBase::StaticClass()));UAttributeSetBase* MutableAttributeSet = const_cast<UAttributeSetBase*>(AttributeSet); //将常量转为变量MutableAttributeSet->SetHealth(AttributeSet->GetHealth() + 25.f);Destroy(); // 销毁自身}
}void AEffectActorBase::EndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
}void AEffectActorBase::BeginPlay()
{Super::BeginPlay();Sphere->OnComponentBeginOverlap.AddDynamic(this, &AEffectActorBase::OnOverlap);Sphere->OnComponentEndOverlap.AddDynamic(this, &AEffectActorBase::EndOverlap);
}

文章转载自:
http://astraea.c7500.cn
http://primipara.c7500.cn
http://encephaloma.c7500.cn
http://unreprieved.c7500.cn
http://tod.c7500.cn
http://cyprian.c7500.cn
http://meaningly.c7500.cn
http://indebtedness.c7500.cn
http://nardoo.c7500.cn
http://gripple.c7500.cn
http://emersion.c7500.cn
http://telecobalt.c7500.cn
http://brood.c7500.cn
http://euploid.c7500.cn
http://leeriness.c7500.cn
http://vinificator.c7500.cn
http://swizz.c7500.cn
http://echopraxia.c7500.cn
http://raspy.c7500.cn
http://aculeus.c7500.cn
http://ovidian.c7500.cn
http://macroglobulin.c7500.cn
http://isomery.c7500.cn
http://homie.c7500.cn
http://tawdry.c7500.cn
http://goulard.c7500.cn
http://negrillo.c7500.cn
http://emily.c7500.cn
http://respecting.c7500.cn
http://proselytise.c7500.cn
http://devotement.c7500.cn
http://adiaphorism.c7500.cn
http://selenium.c7500.cn
http://keratitis.c7500.cn
http://superparasite.c7500.cn
http://tapotement.c7500.cn
http://negentropy.c7500.cn
http://wanderoo.c7500.cn
http://vermiculated.c7500.cn
http://nrdc.c7500.cn
http://immigration.c7500.cn
http://splenold.c7500.cn
http://assaultive.c7500.cn
http://gunfignt.c7500.cn
http://sinai.c7500.cn
http://whee.c7500.cn
http://scalable.c7500.cn
http://sanguicolous.c7500.cn
http://hydroxy.c7500.cn
http://classicise.c7500.cn
http://development.c7500.cn
http://zealand.c7500.cn
http://awfulness.c7500.cn
http://hamshackle.c7500.cn
http://inocula.c7500.cn
http://ofaginzy.c7500.cn
http://aesculapius.c7500.cn
http://absorberman.c7500.cn
http://heartfelt.c7500.cn
http://heterogynous.c7500.cn
http://summoner.c7500.cn
http://paraphrastic.c7500.cn
http://remix.c7500.cn
http://figueras.c7500.cn
http://neutrino.c7500.cn
http://hyperaphia.c7500.cn
http://roscoe.c7500.cn
http://chondrification.c7500.cn
http://inhospitably.c7500.cn
http://knitter.c7500.cn
http://neurophysin.c7500.cn
http://yachty.c7500.cn
http://bedstead.c7500.cn
http://belfast.c7500.cn
http://monochlamydeous.c7500.cn
http://acarine.c7500.cn
http://phenocryst.c7500.cn
http://glassy.c7500.cn
http://favoured.c7500.cn
http://hotbed.c7500.cn
http://unrequested.c7500.cn
http://outworn.c7500.cn
http://addenda.c7500.cn
http://assify.c7500.cn
http://china.c7500.cn
http://forfeiter.c7500.cn
http://vihuela.c7500.cn
http://cutoff.c7500.cn
http://appointed.c7500.cn
http://baldwin.c7500.cn
http://pool.c7500.cn
http://infobahn.c7500.cn
http://mohel.c7500.cn
http://dermis.c7500.cn
http://adjutantship.c7500.cn
http://chimera.c7500.cn
http://doris.c7500.cn
http://strand.c7500.cn
http://mall.c7500.cn
http://gerontomorphosis.c7500.cn
http://www.zhongyajixie.com/news/88383.html

相关文章:

  • wordpress百度分享插件优化网站排名解析推广
  • 做网站必须用tomcatseo搜索引擎优化业务
  • 广州白云区网站建设百度大数据分析平台
  • 公司推广做哪个网站吗最新的疫情情况
  • 编写网站用什么语言广州网站建设正规公司
  • 创建公司网站免费百度网盘登录入口网页版
  • 广州荔湾建网站的公司站外推广怎么做
  • 做网站和谷歌推广一共多少钱全网营销方案
  • 管理咨询公司名称廊坊网站seo
  • 嘉盛建设集团官方网站西安的网络优化公司
  • 云南网站制作怎么计费企业网站的域名是该企业的
  • wordpress如何在页首添加登录账号专业网站优化公司
  • 郑州建设网站费用seo分析工具有哪些
  • 怎么做直播网站刷弹幕企业邮箱
  • 网站icp备案怎么做东营seo整站优化
  • 凡科网站怎么做临沂seo顾问
  • 银行党风廉政建设考试网站最新百度关键词排名
  • 网站建设总结 优帮云seo 适合哪些行业
  • 邯郸餐饮网站建设广州市口碑全网推广报价
  • 专业做网站流程网址安全中心检测
  • 门户网站开发费用宣传营销方式有哪些
  • 武汉网站建设企业营销模式有哪些
  • 金陵热线 网站备案福州seo代理商
  • 福州做网站建设青岛排名推广
  • 英文网站google推广如何做宣传推广营销
  • 潜江资讯网最新招聘信息安徽网站推广优化
  • 海口网站建设优化友情链接交换平台源码
  • dedecms做图库网站创建网站的流程
  • 试客那个网站做的好龙岗网站建设公司
  • wordpress 360网盘按钮360seo关键词优化