Unity-业余2D游戏制作笔记02-Dialogue System for Unity使用

本文记录了使用Unity和Dialogue System for Unity插件开发2D游戏时,如何通过LUA代码修改C#变量,实现任务流程。包括C#变量与Dialogue插件变量的连接,Lua调用C#函数修改数值,以及解决对话系统中的交互问题。
摘要由CSDN通过智能技术生成

 纯新手,仅用于记录个人学习中遇到的问题。

目录

当前目标: C#的变量数值和LUA代码连接

(一)Dialogue System任务流程里简单的LUA代码修改变量

(二)Lua通过调用C#函数,来修改C#里变量的数值。

(三)实现复杂一点的任务流程

     1.创建从任务01切换到任务02的流程

     2.玩家完成任务的过程

     3.NPC背包物品栏物品自检的功能通用化

(四)解决一个小问题:空格键代替鼠标点按Botton按钮

Dialogue System for Unity手册参考内容

 需要后续解决的问题



目前进度:        

        已完成几个人物角色的移动,基本场景,简单的背包和箱子,简单的保存和加载。       

        使用Dialogue System for Unity插件 :

                1.修改UI符合游戏界面,UI对话显示人物的动画

上次留下的问题:

有几个问题需要后续代码修改:

        1.一个NPC说话时,另一个应该停止动作

        2.目前是在UI界面挂载这个Animator的,因此所有NPC调用这个UI都会显示这个挂载的动画

 需要接下来解决的问题:

        1.好感度数值和代码链接,实现插件内的好感度变化时,执行相应的反馈。

        2.靠近NPC后一定范围后,能看到NPC之间头上出现气泡对话
————————————————
版权声明:本文为CSDN博主「solitaryheart」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/solitaryheart/article/details/128741325

        上面需后续代码修改的1和2,都在《业余2D游戏制作笔记03》的文章里得到解决。

当前目标: C#的变量数值和LUA代码连接

        先解决上次遗留其他小问题:1.text文本无法显示变量,另外任务文本部分被UI界面挡住了。

仔细看手册介绍,发现Entry1里var首字母不能大写。改成小写就正常显示了。

        

 修改任务界面在左侧,这样不会被遮挡

        好感度数值Affinity是记录在插件Love/Hate里面的,等下再来处理这个变量。

        先由易到难,尝试一下C#的变量和Dialogue插件的变量的修改方法。

(一)Dialogue System任务流程里简单的LUA代码修改变量

        例如,我在Dialogue Database里面,创建了变量“食物”,初始值是0. 它可以在插件内被修改。    

         实现增加食物的话,可以通过向NPC_Test乞讨。在NPC_Test身上挂载Dialogue System Trigger,Trigger选择On Use。这样的话,还需要加个Usable组件,说明这个NPC_Test是可以use的。另外这个NPC还必须有个Collider,选上is Trigger,这个Trigger的范围,就是允许Player点按触发的范围。(当Player点按触发后,将执行Dialogue System Trigger里面Action的内容:食物+1)

        设置完NPC再设置Player,这个事件的触发由Player来判定。因此在Player上需要挂载Proximity Selector,设置Use Key为Space,即按空格键触发。另外插件内默认有Use Buttom:"Fire2",即鼠标右键也可以触发。触发后,执行Action里面的LUA代码:Variable[“食物”]=Variable[“食物”]+1

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The powerful, top-rated dialogue system used in Disco Elysium, Crossing Souls, Jenny LeClue, Last Epoch, The Last Door, and many many more, the Dialogue System for Unity makes it easy to add interactive dialogue and quests to your game. It’s a complete, robust solution including a visual node-based editor, dialogue UIs, cutscenes, quest logs, save/load, and more. The core is a lean, efficient conversation system. A large collection of included, optional add-ons make it quick and easy to drop conversations into your project and integrate them with other assets. No scripting required. Complete C# source included. Demo | Docs | Tutorials | Forum Free Extras | Free Trial Cinemachine & Timeline Integration! Editor: Visual, node-based dialogue editor Importers for Chat Mapper, articy:draft 1/2/3, Twine, Ink, Neverwinter Nights, Talkit, and CSV Export screenplay format, voiceover asset list, CSV, Chat Mapper, and more I2 Localization support Engine: Dynamic, branching conversation trees Barks and alerts Cutscenes (audio, animation, etc.) Quick Time Events (QTEs) Quest system NPC status & relationship system Easy language localization Save/load without scripting Optional Lua scripting and variable system Comprehensive documentation and tutorials Runtime UIs: GUI-independent; works with all GUI systems, including Unity UI & NGUI Built-in support for Unity UI, NGUI, TextMesh Pro, legacy Unity GUI, & more Input system-independent; works with Unity Input, Rewired, New Input System, etc Modular interfaces: swap in your own UI or cutscene system Several beautiful, fully-customizable UI skins Detailed sci-fi environment & animated model Works in 2D and 3D Works in VR (Oculus Rift, Vive, GVR, etc.) Integration: Components for drop-in integration into existing frameworks Cinemachine & Timeline Action-RPG Starter Kit Adventure Creator Animator Timeline Editor articy:draft Behavior Designer Bolt Visual Scripting
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值