内容来自UE GAS官方文档。
犯了个错误,一开始就去看了GAS详细文档,了解任何一样东西,先理解整体总是最好的。
现在先从UE官方文档看一个大概。
Gameplay Ability: 可以是c++或者蓝图类,定义了Ability的结构以及replication和实例化行为。
Ability Tasks: 写在c++中,经常性在执行完后调用相关delegate,例如可能与cancel GA有关。
Gameplay Atttributes: 属性,如生命值
Gameplay Effects: 更像是各种buff和debuff
Ability System Component: Any Actor that interacts with the Gameplay Ability System must have an Ability System Component。This Component will activate Abilities, store Attributes, update Effects, and handle interactions between Actors
GameplayAbility(GA)
下面是几个在ASC中的函数
grantability
-
GiveAbility
: Specifies the Ability to add with anFGameplayAbilitySpec
, and returns anFGameplayAbilitySpecHandle
. -
GiveAbilityAndActivateOnce
: Specifies the Ability to add with anFGameplayAbilitySpec
, and returns anFGameplayAbilitySpecHandle
. The Ability must be instanced and able to run on the server. After attempting to run the Ability on the server, aFGameplayAbilitySpecHandle
will be returned. If the Ability did not meet the required criteria, or if it could not execute, the return value will be invalid and the Ability System Component will not be granted the Ability.
revoke abiliy, 通过FGameplayAbilitySpecHandle
-
ClearAbility
: Removes the specified Ability from the Ability System Component. -
SetRemoveAbilityOnEnd
: Removes the specified Ability from the Ability System Component when that ability is finished executing. If the Ability is not executing, it will be removed immediately. If the Ability is executing, its input will be cleared immediately so that the player cannot reactivate or interact with it any further. -
ClearAllAbilities
: Removes all Abilities from the Ability System Component. This function is the only one that does not require anFGameplayAbilitySpecHandle
.
基本使用
CanActivateAbility: 是否能使用,例如测试如果技能不能使用,设置icon为灰色。
CallActivateAbility:关于使用Ability,经常先CanActivateAbility之后用这个
主要需要覆写的函数是ActivateAbility,
CommitAbility:用来apply the cost of executing the ability. 例如扣蓝。
CancelAbility:provides a mechanism to cancel the Ability, although the Ability's CanBeCanceled
function can reject the request。和CommitAbility不同,this function is available for callers outside of the