Gameplay Ability System - UE4


Intro简介

So, what's a GameplayAbility?

Basically, they're like the abilities you have in Dota or equivalent games. You can cast a fireball, and this fireball hits a player, explodes (doing a set amount of damage), and sets everyone in the radius of the explosion on fire (doing damage over time). Meanwhile, the player who cast the fireball loses some mana and is put on cooldown.

You could use Epic's GameplayAbility plugin to do all of those things. The module is hard to wrap your head around, but once you learn how powerful they can be and how to properly make use of them, they can make your life much, much easier.

But why use this over rolling your own system?

GameplayAbilities can come in handy if your game is in need of a powerful skill, buff and attribute system that is both easy to extend and crazy-efficient to replicate. This can do wonders for people working on a multiplayer RPG with a lot of skills/classes or perhaps even a MOBA, but you can use this system for pretty much any game you want. The main problem is that it isn't the easiest to comprehend, quite big and may get a little in your way the further you stray too far away from this multiplayer RPG ideal, so not every game will get the same mileage out of it.

Well, that sounds like a dream, but where do I get it?

Well, first of all, GameplayAbilities is a code module that used to be integrated into UE4's source, but since this current version (4.15, that is, people from the future) has been moved into a separate plugin that is delivered alongside the Unreal Engine, so that it may not take away space in your games if they do not make use of the system. This system does not actually originate as a built-in engine feature, but has, in fact, been kindly left in there from the developers of Paragon and Fortnite for third parties to enjoy. Unfortunately, due to these unique circumstances, the module as a whole is quite messy, poorly (read: barely at all, your best bet are code comments and even those are only there like half the time) documented, and rarely updated and cleaned up.

It is also not 100% exposed to blueprints, partially, but not entirely, due to a lot of the system abusing a lot of engine trickery and magic to work as well as they do, so if you never worked with C++ in the context of UE4, you may want to turn back and maybe do a little tutorial on that now, because this tutorial will make for a poor first learning experience.

In other words, it is a total flippin' pain in the buttocks to wrap your head around, but that's where this guide comes in to help ya. Epic Developer Dave Ratti has an example GitHub project which goes through some basic examples to get you started, but ignores the fine lines and goes for broad strokes. The project itself has been pretty hidden, however, and (at the time) doesn't really show up on Google or any real search about the GameplayAbilities plugin, so it hasn't been as helpful as a full-fledged guide. Moreover, now that GameplayTags are properly integrated into the editor by default (a system GameplayAbilities itself uses at every corner of the way, acting as GameplayAbilities' backbone), setup has never been any easier!

With all that said, let's get started, finally.

注:GitHub工程好像已经不能用了,请参考Epic官方的ActionRPG工程,可以在虚幻商城中免费下载。

简介直接粘贴Epic Wiki中GAS的Intro部分,懒得翻译了,英文苦手的朋友,谷歌翻译一下大意即可,总结一下,就是这个系统很NB,被用于《堡垒之夜》、《Paragon》。但这个系统很复杂(据说核心部分就超过2万行代码,加上相关部分会到10万行代码)、上手较难,但学会了以后事半功倍!

启用GAS

Editor

在插件管理中启用GameplayAbilities插件,请忽略([UNSUPPORTED])。


C++

在使用该插件的module的build.cs文件中增加对模块GameplayAbilities,GameplayTags,GameplayTasks的引用。可以看出共有三个模块。其实Gameplay Tag和Gameplay Task也可以应用于Gameplay Ability System之外的系统。

相关知识点:

Basic

  • Gameplay Ability System Component(GAS组件)
  • Gameplay Attribute(属性)
  • Gameplay Tag(标签)
  • Gameplay Effect(效果)
  • Gameplay Ability(能力)
  • Gameplay Task & Ability Task
  • Gameplay Cue

Advanced

  • Gameplay Effect Execution Calculation
  • Gameplay Event
  • Targeting(目标选择)

在我的文集中,我将逐个解析这些知识点。由于GAS系统相当复杂,我只涉及到了基本部分,更深入的了解还需要读者自己努力。(看源代码、查资料等)。但要注意的是,GAS是开发《Fortnight》和《Paragon》过程中的产物,UE官方还没有特地为通用性来大力重构这个系统(近期也不会,因为不在UE4的Roadmap上,他们认为现在这个系统还行,重构它的优先级不高,但开发团队会持续更新ActionRPG项目,我们可以跟踪这个项目进行学习),所以这个系统中会遗留一些与上述两个游戏关联很紧密的部分。

高级部分停更,等我吃透整个ActionRPG(UE4.22发布后,该项目会更新一个版本)对GAS有更深的理解后有机会再更吧!

在ActionRPG的分析中,会再次涉及GAS,并探讨其Advanced部分:
解析ActionRPG(施工中)

参考工程

这个系列文章的代码几乎都来自这个工程。

Action RPG

文档链接:https://docs.unrealengine.com/en-us/Resources/SampleGames/ARPG
游戏内截图

其他参考资料

有好心人在github上做了关于Gameplay Ability System相关资料的整理!
https://github.com/Pantong51/GASContent

由于ActionRPG项目中除了GAS外,还有背包系统,UI系统,资源管理等内容,所以我先看其他更简单的项目代码。

  • Woppin's Code
  • aa1000

你可能感兴趣的:(Gameplay Ability System - UE4)