obsidian/笔记文件/2.笔记/第二关的歌声.md
2025-03-26 00:02:56 +08:00

72 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

歌声也是一个预制体
结构相对简单
![[Pasted image 20230707140014.png]]
自身是一个圆形图片
还有一个圆形碰撞器,
![[Pasted image 20230707140117.png]]
相关属性
![[Pasted image 20230707140322.png]]
更新函数,控制的是旋转和缩放,音频的播放
![[Pasted image 20230707140433.png]]
有一个设置是否唱歌状态的函数,也是直接修改布尔的
![[Pasted image 20230707145245.png]]
可以看到,第二关的主角,子物体是有歌声这个预制体的
![[Pasted image 20230707145440.png]]
回到第一关
可以看到,第一关的主角,子物体是没有歌声这个预制体的
![[Pasted image 20230707150141.png]]
脚本逻辑,歌声也是在代码里声明出来的
![[Pasted image 20230707150236.png]]
![[Pasted image 20230707150248.png]]
有判空就好
![[Pasted image 20230707150304.png]]
回到第二关
按键K和停止歌唱的StopSinging布尔判断是否要唱歌
修改动画控制器的布尔进行动画播放
![[Pasted image 20230707150441.png]]
而且可以看到,动画控制器里,是任意状态,都能切换到唱歌动画的,也都是通过这个布尔
![[Pasted image 20230707150642.png]]
![[Pasted image 20230707151103.png]]
歌声预制体是自带音频播放器的
![[Pasted image 20230707151216.png]]
运行时候按k的效果
![[Pasted image 20230707151428.png]]
补充说明,不需要按照流程从第一关过渡到第二关
直接切换到第二关就可以运行了,无报错
![[Pasted image 20230707151545.png]]
唱歌的时候,加点限制,是不让移动的
![[Pasted image 20230707151844.png]]