首页 > 技术文章 > 《Note --- UE4 --- Blueprint_Overview_HowTo》

DeanWang 2017-08-15 21:30 原文

Web: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/GettingStarted/index.html 

1. Blueprint-specific markup available in Unreal Engine's C++ implementation enables programmers to create baseline systems that can be extended by designers.

2. Each game can specify the default Level Blueprint class in the DefaultGame.ini config file. The Level Blueprints for all new maps will be created using this class allowing for game-specific additions and functionality.

3.Data-Only Blueprint is a Blueprint Class that contains only the code (in the form of node graphs), variables, and components inherited from its parent. These allow those inherited properties to be tweaked and modified, but no new elements can be added. These are essentially a replacement for archetypes and can be used to allow designers to tweak properties or set items with variations.

Class Defaults can be accessed at runtime for data-only Blueprints through the GetClassDefaults Blueprint node. Please see the Get Class Defaults for more information.

4.Blueprint Interface is a collection of one or more functions - name only, no implementation - that can be added to other Blueprints. Any Blueprint that has the Interface added is guaranteed to have those functions. The functions of the Interface can be given functionality in each of the Blueprints that added it. This is essentially like the concept of an interface in general programming, which allows multiple different types of Objects to all share and be accessed through a common interface. Put simply, Blueprint Interfaces allow different Blueprints to share with and send data to one another.

这个有点类似于多态,先定义一些没有实现只有名字的blueprint接口,然后添加使用这些接口的blueprint必须具体实现这些接口;

5.Blueprint Macro Library is a container that holds a collection of Macros or self-contained graphs that can be placed as nodes in other Blueprints. These can be time-savers as they can store commonly used sequences of nodes complete with inputs and outputs for both execution and data transfer.

Macros are shared among all graphs that reference them, but they are auto-expanded into graphs as if they were a collapsed node during compiling. This means that Blueprint Macro Libraries do not need to be compiled. However, changes to a Macro are only reflected in graphs that reference that Macro when the Blueprint containing those graphs is recompiled.

6. Storing Macros in a Blueprint Macro Library makes them accessible to Blueprint Classes and Level Blueprints throughout your project.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/MacroLibrary/index.html

在level blueprint里面创建一个macro,那么在level blueprint里面可以直接访问这个宏节点,如果双击这个宏节点就会打开其内容,但是只做这些发现这个宏在其他的class blueprint里面是搜索不到的,从文档里看是需要添加到一个macro library(一个资源)的库里面才行,这样这个宏才能够变成全局的, 我估计对于一些判断平台的部分应该写成一个宏;那么怎样加到macro library里面?

如果直接在macro library里面直接创建一个新的宏,那么它就可以被全局引用; 但是如果这个宏中想引用变量怎么办? 好像宏也确实只能引用全局变量

7. 创建class blueprint,可以两种方法,一种是创建好blueprint资源,然后拖到场景中成为actor实例; 一种是将static mesh等资源拖到场景中成为actor,然后在它的detail面板中添加一些需要的component,再点击detail里面的”Blueprint/Add Script”来创建blueprint;

8. GetPlayerPawn接口来获取当前控制的角色; Character类有一个函数是”Launch Character”可以影响当前character的位置,比如角色碰到炸弹被炸到一边可以用这个,但是要记得”cast to Character”因为只是character的接口;

9. 关于debug,如果场景中有多个class blueprint的实例, 它只会针对于创建最早那个进行监测; 比如说, 一个class blueprint有个box会被overlap的时候触发一个事件, 但只有第一个被放到场景中的实例会被监测到,当主角与第二个实例发生box的接触,是不会发生断点触发的; 只是与放入场景最早的实例有关, 与实例的名字, 是否选择这个实例没有关系;

不对; UE4是可以在运行时选择监视哪个实例的(打开你的class blueprint工具栏中):这个选择这个就是监视当前class blueprint的所有实例, 也可以选择监视其中一个:默认的选择应该是最早拖入场景中的那个实例;

10. Timeline nodes are special nodes within Blueprints that allow for simple time-based animation to be quickly designed and played back based on in-game events. Timelines are somewhat like simple Matinee sequences in that they allow simple values to be animated and events to be fired off over time. These can be edited directly inside the Blueprint editor by Double-clicking on the Timeline in the Graph tab or in the My Blueprint tab. They are specifically built for handling simple, non-cinematic tasks such as opening doors, altering lights, or performing other time-centric manipulations to Actors within a scene.

Web: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Timelines/index.html

 


 

 

 

Web : https://docs.unrealengine.com/latest/INT/Engine/Blueprints/BP_HowTo/index.html

Project: D:\EngineStudy\Unreal\4.14\TestProject\HowTo_BP

1. 一个class blueprint怎样引用场景中其他的actor?

给这个class blueprint添加一个Actor类型的变量,然后将其设定为可见(眼睛icon点开),拖这个class blueprint到场景中,创建一个实例,发现在该实例下面有Default category, 找到之前变量用吸管吸取场景中的actor即可指定; 同样我们也可以吸取一个class blueprint类型的actor, 比如我们创建一个class blueprint资源取名为”TriggleBox_Blueprint”, 将其拖到场景中创建一个实例为” TriggleBox_Blueprint_0”, 对于之前的class blueprint我们可以用吸管吸取这个” TriggleBox_Blueprint_0”, 在blueprint的event graph窗口里面可以利用接口”Cast To TriggerBox_Blueprint”来检测当前引用的是否是特定类型;

注意就是,我们创建一个class blueprint资源,其实就是创建了一种新的类型,故而对其可以使用cast机制;

2. Blueprint 之间如何交互?

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/BlueprintCommsUsage/index.html

3. Event Dispatchers:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/BP_HowTo/EventDispatcher/index.html

project : D:\EngineStudy\Unreal\4.14\TestProject\HowTo_Event

当一个event dispatchers被调用,那么bound 到它的event和其内部操作都会被执行;

我们在class blueprint ThirdPersonCharacter里面创建了一个event dispatchers, 名为StartFire, 在level blueprint里面我们就可以通过ThirdPersonCharacter的实例来引用其内部定义的StartFire事件;如下图:

然后自动出现两个节点:

Bind Event to StartFire和StartFire_Event_0 这样在level blueprint里面就绑定了这个事件(虽然这个事件是在class blueprint里面定义的, 这属于event之间的交互了),然后在bind的这里去定义这个event触发了就去干什么行为; 事件是, 一个定义在一个class blueprint A里面event可以在多个地方访问(只要拿到了event), 在各个地方绑定bind后可以有不同的行为, 比如这里是SpawnActor;

总结来说,在class blueprint A里面新增一个event, 然后在A中一些逻辑下调用(call)这个event; 在class/Level blueprint class B中引用到 class blueprint A, 然后绑定A中的那个event, 并且写入这个event发生时接下来干什么的逻辑; 这样,当A中的event触发, B中这个event下面的逻辑也会进行;

另外, 在右键中搜索”Add Custom Event”可以新增一个event节点, 但是这个节点不会出现在”Event Dispatchers”的category里面; 

在自己的class blueprint里面新增加一个event, 即使自己使用(此时event的调用就像函数功能差不多了), 一般要在beginplay的event上绑定这个event:

SetAlarmLightColor 是自己的事件, ChangeAlarmLightColor是event触发时候的执行内容, 脱出BeginPlay的线搜索assign可以找到事件; 事件不绑定不行!哪怕是自己的事件!

4. Interfaces:

Web: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/BP_HowTo/Interfaces/index.html

Project: D:\EngineStudy\Unreal\4.14\TestProject\HowTo_Interface

可以先定义一个blueprint interface的资源, 在资源里面声明一个接口函数(没有实现), 然后在另外一个class blueprint的Class Setting里面去add进来这个blueprint interface资源; 然后我们在这个class blueprint里面的event graph里面就可以右键里面查找到这个interface资源里面声明的接口函数,然后具体定义它在这个class blueprint里面干什么事情; 其实我们可以右键搜索到这个接口相关的两个东西:

IsDestructible是我们在一个blueprint interface资源里面声明的接口名字; (在有的地方,比如控制主角的class blueprint里面还看到了”Is Destructible?(Message)的item, 不确定都是有什么区别”, 区别好像是有没有compile操作)

By using a Blueprint Interface we can make a general function that is called in all Blueprints that implement that interface and function, and then determine what script is executed on each individual Blueprint.

总结来说: 接口就是, 创建一个blueprint interface资源, 然后其他class blueprint增加这个资源的引用, 就可以在自己的event graph里面调用这个接口内部声明那个函数, 然后做一些特定行为; 当引用这个接口的其中一个class blueprint对这个函数进行了调用(需要指定target,也就是说要指定调用哪个class blueprint的这个接口事件的监听执行行为, 如地震发生调用接口”地震”, 就要指定哪个actor的接口监听事件被触发,是树的还是车的,其中树和车都对”地震”这个接口有具体的实现), 那么其他class blueprint里面的这个接口对应的event也就会触发; 这样,一个class blueprint就对其他class blueprint进行了发消息,具有这个接口的函数的event的class blueprint就像一直在监听这个事件;

如上图, class blueprint里面引用的是”IsDestructible?”是在调用,发起所有事件event的相应; class blueprint里面引用的是”Event Is Destructible?” 是在监听,当别人调用这个函数时候本地就进行预定义好的下面的逻辑;

5. 怎样控制一个角色走动?

通过分析FirstPerson的例子, 得知, 应该是, 一个character class的blueprint, 其中使用到一个skeletalmesh component,该component使用的Animation Mode是”Use Animation Blueprint”, 设定一个Anim Class是预定义好的Animation blueprint; 一个animation blueprint里面包含了这个skeletal的所有行为状态, 包含状态(state, 指的是各种动作,如跑,走等Animation Sequence)和各个状态间切换的规则(rule, 如FPP_Idle to FFP_JumpStart这样的两个状态间的切换), 这个规则其实就是一个状态机, 在animation blueprint里面是AnimGraph;

其中对于Animation Sequence其实就是一个个动画帧序列, 在它这种资源的editor里面可以在这个动画中添加notify, 比如跳到空中时候播放一个声音这样的行为;

6. The BlueprintCompilerCppBackend module (found here: Engine\Source\Developer\BlueprintCompilerCppBackend\) converts the Blueprint syntax tree into C++. TheBlueprintNativeCodeGen module (found here: Engine\Source\Developer\BlueprintNativeCodeGen\) does a lot of magic while cooking and packaging.

Web: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/TechnicalGuide/NativizingBlueprints/Advanced/index.html

7. 关于可破碎物体Destructible Component, 它的blueprint里面有”Simulation Generates Hit Event”, 按照注释, 是说, 当破碎时候会触发一个”Hit”的event: “Should ‘Hit’ events fire when this object collides during physics simulation”;

8. UI中的每个控件都会有bind行为,bind到一个操作上,一般bind到主角身上的某个属性, 可以使用GetPlayerCharacter节点来获取主角, 将输出pin转换为特定actor”Cast To FirstPersonCharacter”, 然后访问其内部成员变量;

9. 事件”Event Construct”, 构造的时机;

 

10. 动画部分有一个比较不错的example,官网给的:ExampleContent 这个,其中地图是Animation.umap这个;

11. 在新版的editor中发现,postprocess里面

, Screen Percentage renders the scene at a lower resolution and then scales it up. The value represents a percentage of the overall resolution of the scene; 这个似乎很有用, 好像是upscale的机制;

推荐阅读