内容来自官网ARPG文档https://docs.unrealengine.com/4.27/en-US/Resources/SampleGames/ARPG/GameplayAbilitiesinActionRPG/

Code Overview

Most Unreal Engine 4 (UE4) projects start from one of the existing templates, or as a clone of an existing sample project.

类似于RPGTypes.h这样内部定义了一些通用的数据类型和delegate,结构上更清晰,避免循环引用。

几乎所有游戏都会先定义一个继承于APlayerController的类似RPGPlayerControllerBase的类。在ARPG中,主要处理inventory.

RPGCharacterBase.h:蓝图Character继承自的地方。

RPGGameInstanceBase.h: 适合存放global gameplay data.

RPGBlueprintLibrary.h: Exposes game-specific Blueprint functions that are not tied to a specific Actor, almost every game will need one or more of these.与具体的Actor联系不紧密的蓝图可调用函数。

RPGSaveGame.h:用于存档

RPGAssetManager.h:Subclass of the AssetManager that is used in the inventory system.

RPGInventoryInterface.h: Native interface enabling RPGCharacterBase to query RPGPlayerControllerBase about inventory without doing manual casts.

Cast在UE中似乎是一个很费的操作。

Items/RPGItem.h and Subclasses: Different inventory item types.

Abilities/RPGAbilitySystemComponent and Others: Used in the ability system as described in Gameplay Abilities in ARPG.

ActionRPGLoadingScreen Module:用来展示texture的loading screen module, 独立为一个Module是因为需要在游戏加载前就加载。

很多其他游戏会有一个Editor Module扩展编辑器。

Inventory and Asset Manager

游戏中与几个基本的类型:武器、技能、药水等都继承自URPGItem, 并且都定义在了DefaultGame.ini中

每个基类也提供了UI支持,像是icon等。

在playercontorllerBase中有两个映射。一个是从inventory的slot到Item*的,另一个是从Item*到ItemData的。

LoadPrimaryAssets会对一类asset逐个load.之后存储在gameinstance中。LoadPrimaryAssets会使得asset一直在内存中直到Unload被调用。

实际的保存使用了 SaveGameToSlot蓝图函数,将信息存在disk上

Packaging for Release

要保证including only the content it needs

The "CookRule=AlwaysCook" section of the Primary Asset Type configuration file causes all items in your project's Content folder to be cooked into the final game。

Once we verified that the packaged game was working correctly and all of the project's content was included we then took a look at ways to reduce download and memory size

为了减少空间消耗

1.Disable any Plugins that are not being used. Doing this for ARPG reduced the overall project size by 30 MB.
2.Enabled the Exclude editor content when cooking flag that can be found in Packaging settings. Doing this will prevent the project from shipping any content in the UE4 Editor folders like /Engine/EditorMaterials.

4. Using the Size Map tool available from the Asset Audit window

5. Temporarily enabled the For Distribution checkmark box in Project Settings > Packaging and changing the Build Configuration from Development to Shipping to get a better idea of what the final size of ARPG would be。

Balancing Blueprint and C++

Broadly speaking, things in a game can be divided into Logic and Data

C++ vs Blueprints 

  • Network Replication: Replication support in Blueprints is straightforward and is designed to be used in smaller games or for unique one-off Actors. If you need tight control over replication bandwidth or timing you will need to use C++.

  • Faster Iteration: It is much quicker to modify Blueprint logic and preview inside the editor than it is to recompile the game, although hot reload can help. This is true for both mature and new systems so all "tweakable" values should be stored in assets if possible.

  • Better For Flow: It can be complicated to visualize "game flow" in C++, so it is often better to implement that in Blueprints (or in custom systems like Behavior Trees that are designed for this). Delay and async nodes make it much easier to follow flow than using C++ delegates.

  • Easier Data Usage: Because storing data inside Blueprint classes is much simpler and safer than inside C++ classes; Blueprints are suitable for classes that closely mix Data and Logic.

在DefaultEngine.ini中

[CoreRedirects]
+ClassRedirects=(OldName="BP_Item_C", NewName="/Script/ActionRPG.RPGItem", OverrideClassName="/Script/CoreUObject.Class")
+ClassRedirects=(OldName="BP_Item_Potion_C", NewName="/Script/ActionRPG.RPGPotionItem", OverrideClassName="/Script/CoreUObject.Class")
+ClassRedirects=(OldName="BP_Item_Skill_C", NewName="/Script/ActionRPG.RPGSkillItem", OverrideClassName="/Script/CoreUObject.Class")
+ClassRedirects=(OldName="BP_Item_Weapon_C", NewName="/Script/ActionRPG.RPGWeaponItem", OverrideClassName="/Script/CoreUObject.Class")

The above code block uses the Core Redirects system to convert all references to the Blueprint BP Item C to instead reference the new native class RPGItem。The OverrideClassName option is required because it needs to know that it is now a UClass instead of a UBlueprintGeneratedClass.

Performance Concerns

Broadly, the main difference is that executing each individual node in a Blueprint is slower than executing a line of C++ code, but once execution is inside a node, it's just as fast as if it had been called from C++. For example, if your Blueprint class has a few cheap top-level nodes and then calls an expensive Physics Trace function, converting that class to C++ will not improve performance significantly. But, if your Blueprint class has a lot of tight for loops or lots of nested macros that expand into hundreds of nodes, then you should think about moving that code to C++. One of the most critical performance problems will be Tick functions. Executing a Blueprint tick can be much slower than a native tick, and you should avoid tick entirely for any class that has many instances. Instead, you should use timers or delegates to have your Blueprint class only do work when it needs to.

The best way to find out if your Blueprint classes are causing performance problems is to use the Profiler Tool.

Architecture Notes

Avoid Casting to Expensive Blueprints

Avoid Cyclical Blueprint References

  • Think about Async Loading: As your game grows larger you will want to load assets on demand instead of loading everything up front when the game loads. Once you reach this point, you will need to start converting things to use Soft references or PrimaryAssetIds instead of Hard references. The AssetManager provides several functions to make it easier to async load assets and also exposes a StreamableManager that offers lower level functions.

Avoid Referencing Assets from C++ classes

UE官网ARPG游戏学习笔记1相关推荐

  1. Docker学习笔记 [声明:基于官网教程的学习笔记]

    前言 对于我博客近来一直没有更新的原因,从2020年11月左右吧,开始忙着找工作的事情,11月底左右,学校举办了2021届校招,来学校的校招企业其实没几个比较好的(根据上一届学长得知,有的企业是培训机 ...

  2. [译] 通过官网 Go 语言学习笔记 | How to Write Go Code

    原文:How to Write Go Code 一些基本概念 下载 & 安装:golang.org/doc/install go tool:安装好 Go 之后自带的 cmd 工具,用于 fet ...

  3. Vue官网2文档笔记

    文章目录 $event $on Class 与 Style 绑定 对象语法 列表渲染 v-for 中使用对象 事件处理 事件修饰符 插槽 具名插槽 解构插槽 prop 动态组件&异步组件 访问 ...

  4. 【慕课网】Web学习笔记———CSS3 (一)

    [Web学习笔记]CSS3 (一) CSS3代码语法 CSS注释代码 CSS样式 内联式css样式 嵌入式css样式 外部式css样式 权值 CSS3选择器 标签选择器 类选择器 ID选择器 类与ID ...

  5. 关于对【网页游戏官网-部分游戏页面特效实现思路】的阐述

    [版权声明]未经博主同意,谢绝转载!(请尊重原创,博主保留追究权) https://blog.csdn.net/m0_69908381/article/details/129957557> 出自 ...

  6. 学习【全栈之巅】Node.js + Vue.js 全栈开发王者荣耀手机端官网和管理后台笔记(2.10-2.12)

    [全栈之巅]Node.js + Vue.js 全栈开发王者荣耀手机端官网和管理后台 本项目是 学习Bilibili 全栈之巅 视频教程相关源码和体会 https://gitee.com/blaunic ...

  7. 学习【全栈之巅】Node.js + Vue.js 全栈开发王者荣耀手机端官网和管理后台笔记(2.8-2.9)

    [全栈之巅]Node.js + Vue.js 全栈开发王者荣耀手机端官网和管理后台 本项目是 学习Bilibili 全栈之巅 视频教程相关源码和体会 https://gitee.com/blaunic ...

  8. 学习【全栈之巅】Node.js + Vue.js 全栈开发王者荣耀手机端官网和管理后台笔记(1.1-2.5)

    [全栈之巅]Node.js + Vue.js 全栈开发王者荣耀手机端官网和管理后台 本项目是 学习Bilibili 全栈之巅 视频教程相关源码和体会 https://gitee.com/blaunic ...

  9. Kubernetes四探(官网Tutorials的学习)

    2022年10月2日: 国庆是充电的好机会.继续学习官网的Tutorials. 先推荐一个学习kubernetes 的好去处. https://labs.play-with-k8s.com 就是有点慢 ...

  10. 从零开始学前端:jQuery官网 --- 今天你学习了吗?(CSS:Day26)

    从零开始学前端:程序猿小白也可以完全掌握!-今天你学习了吗?(CSS) 复习:从零开始学前端:标签渐变和媒体查询 - 今天你学习了吗?(CSS:Day25) 文章目录 从零开始学前端:程序猿小白也可以 ...

最新文章

  1. lucene 使用教程转
  2. python 画图 内存-10种检测Python程序运行时间、CPU和内存占用的方法
  3. 【涛声依旧】华为的“大服务”
  4. 计算机网络全部实验,计算机网络综合实验
  5. 深度学习之卷积神经网络(3)卷积层实现
  6. dll文件懒加载_一步步学习NHibernate(5)——多对一,一对多,懒加载(2)
  7. 【计算机系统】指令流水线
  8. java 集合类 *****
  9. 页面s升级中_你的电脑要不要升级内存?怎么升级?答案都在这里
  10. fatal error: hb.h: 没有那个文件或目录
  11. 社会计算经典谈——书籍销量预测
  12. DXperience中文视频教程(下)
  13. 简繁体计算机术语对照表
  14. Python基础学习资料视频下载链接
  15. coreldraw常用快捷键
  16. VSCODE Vue插件
  17. 牛顿吼 苹果把老子头砸了 于是 爱翁发现 谭
  18. (二)ElasticSearch实战基础教程(ElasticSearch入门)
  19. JAVA GUI(图形用户界面)
  20. 线性内插interp1函数用法

热门文章

  1. IP-Guard准入控制网关实现机制
  2. 吴恩达深度学习02-3.567 Batch Normalization(BN)
  3. 升级openssh后出现问题(kex_exchange_identification: client sent。。。。。)
  4. win7怎样更改桌面计算机图标,教您电脑如何更改桌面图标
  5. 2019 年第 25 周 DApp 影响力排行榜 | TokenInsight
  6. 高项笔记1.信息化和信息系统
  7. 几道经典的面试题53
  8. 从高考到程序员,一生无悔的选择,码农的成长之路
  9. Persistent Bugger 实践练习
  10. 怎么从身份证号码批量提取出生年月日?