查看: 773|回复: 10

[可视化蓝图脚本] 【Event Dispatchers | Unreal Engine】

[复制链接]

1

主题

342

帖子

7万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
75866
发表于 2016-6-27 15:58:26 | 显示全部楼层 |阅读模式



When an Event Dispatcher is called, any Blueprints that implement and have Events bound to the Event Dispatcher will also execute when the Event Dispatcher is called. In other words, whenever the Event Dispatcher is called, any Events that are bound to it are also called allowing you to execute multiple Events at once from a single source.

This page will show you how to set up an Event Dispatcher and Bind an Event to the Event Dispatcher.

For this example we will allow the player to press a key which will cause a fire particle effect to spawn inside of a bush.

For this guide we are using the Blueprint Third Person template with Starter Content enabled.

In the Content Browser, under the Content/ThirdPersonBP/Blueprints folder, open the ThirdPersonCharacter Blueprint.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Under the My Blueprint window, click the Add Event Dispatcher button and name it StartFire.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Right-click in the graph window and add an F Key Event.

Drag the StartFire Event Dispatcher into the graph and select Call.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Connect the F Key Event to the Call StartFire Event Dispatcher.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Whenever the F key is pressed, any Blueprints that have an Event bound to this Event Dispatcher will also be executed.

Compile and Save then close the Blueprint.

In the Content Browser under Content/StarterContent/Props, drag the SM_Bush into the level.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



From the Main Toolbar, click the Blueprints button then select Open Level Blueprint.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Right-click inside the graph and select the Create a Reference to SM_Bush node.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Here we are getting a reference to the SM_Bush inside our level.

Don't see the node listed above Select the SM_Bush inside your level then try again.

Right-click in the graph and add an Event Begin Play and Get Player Character node.

Off the Get Player Character node, search for and add the Cast To ThirdPersonCharacter node.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



This will allow us to access the Events, Functions, Variables or Properties inside the ThirdPersonCharacter Blueprint.

Please see the Casting documentation for more information regarding Blueprint Cast Nodes.

Off the As Third Person Character pin, search for and use the Assign Start Fire node.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



This will create two new nodes, a Bind Event node and a Custom Event. Whenever the Event Dispatcher is called inside our Character Blueprint, since we are binding that event, the Custom Event and anything connected to it will also be executed. Any Blueprints that have Events bound to the Event Dispatcher will also be executed.

Off the Custom Event, add a Spawn Actor from Class node (with Class set to Blueprint_Effect_Fire).

Drag off the SM_Bush to Get Actor Transform and use that as the Spawn Transform for the Spawn Actor node.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



Once all nodes are connected, your graph should look similar to above.

Click Compile, close the Level Blueprint, then click Play to play in the editor.

【虚幻4翻译文档-Event Dispatchers | Unreal Engine】[虚幻4中文文档]



When you press the F key, the fire effect will spawn inside the bush.

For more information on working with Event Dispatcher and sample use cases, refer to the Related Topics below.



   



   



      




   


      相关页面

  




       事件调度器








      蓝图交互的用法








      蓝图用户指南




回复

使用道具 举报

0

主题

905

帖子

2956

积分

vip会员

Rank: 1

积分
2956
发表于 2016-7-2 19:54:06 | 显示全部楼层
最喜欢全套的了
回复 支持 反对

使用道具 举报

0

主题

874

帖子

2867

积分

vip会员

Rank: 1

积分
2867
发表于 2016-7-4 02:16:26 来自手机 | 显示全部楼层
谢谢楼主分享哈!
回复 支持 反对

使用道具 举报

0

主题

899

帖子

2981

积分

vip会员

Rank: 1

积分
2981
发表于 2016-7-4 11:58:07 来自手机 | 显示全部楼层
楼主辛苦
回复 支持 反对

使用道具 举报

0

主题

837

帖子

2744

积分

vip会员

Rank: 1

积分
2744
发表于 2016-7-9 18:49:41 来自手机 | 显示全部楼层
秒了 秒了  秒了  这东西 秒了
回复 支持 反对

使用道具 举报

0

主题

893

帖子

2947

积分

vip会员

Rank: 1

积分
2947
发表于 2016-7-13 07:21:44 | 显示全部楼层
好吗
回复 支持 反对

使用道具 举报

0

主题

864

帖子

2841

积分

vip会员

Rank: 1

积分
2841
发表于 2016-7-16 13:39:41 来自手机 | 显示全部楼层
加油摸摸大,感谢楼主分享
回复 支持 反对

使用道具 举报

0

主题

892

帖子

2904

积分

vip会员

Rank: 1

积分
2904
发表于 2016-7-18 02:40:36 来自手机 | 显示全部楼层
什么鬼???看着很不错的样子啊!
回复 支持 反对

使用道具 举报

0

主题

852

帖子

2878

积分

vip会员

Rank: 1

积分
2878
发表于 2016-7-18 11:20:36 | 显示全部楼层
这个不会又是超级贵吧.
回复 支持 反对

使用道具 举报

0

主题

853

帖子

2832

积分

vip会员

Rank: 1

积分
2832
发表于 2016-7-19 17:12:53 | 显示全部楼层
版主我爱你
回复 支持 反对

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | enginedx注册

本版积分规则

 
 



邮件留言:


 
返回顶部