unity 小怪播放动画导致ui抖动

我的血条的canvas是使用World Space模式,然后点位挂载到小怪里的,小怪会自己走来走去,血条ui也是实时更新,z轴和相机平行。一开始大概是长下面这个样子的,一直忙活背包ui的学习,没怎么看战斗,结果今天发现小怪播动画的时候会导致ui抖动,上网搜了搜也没找到相应的文章,gpt给的答案也不是很好做。自己想了个思路

csharp 复制代码
        UIbar.position = barPoint.position;
        // 这样应该的
        // UIbar.forward = cam.forward;
        // 项目中用的是这个,反向
        UIbar.forward = -cam.forward;

我的游戏是一个rpg的类型,小怪只有到可攻击范围内才会播放动画,并且停下来。这个时候我就在想,如果知道了agent.isStopped为true了,就不再更新UI血条的位置,试了一下,完美的解决,不知道是不是最优解,简单的提供一个思路

csharp 复制代码
        #region //"这一段主要为了更新血条ui位置"

        // 血条跟随敌人
        if (UIbar == null)
        {
            return;
        }

        #region "测试血条还会不会闪 应该是不会闪了"
        EnemyControler e = GetComponent<EnemyControler>();
        if (e == null || e.agent.isStopped) return;

        #endregion


        UIbar.position = barPoint.position;
        // 这样应该的
        // UIbar.forward = cam.forward;
        // 项目中用的是这个,反向
        UIbar.forward = -cam.forward;
相关推荐
speedoooo16 小时前
在现有App里嵌入一个AI协作者
前端·ui·小程序·前端框架·web app
霍格沃兹测试学院-小舟畅学17 小时前
Playwright MCP在UI自动化测试中的定位与思考
ui
Just_Paranoid18 小时前
【Android UI】Android 颜色的表示和获取使用指南
android·ui·theme·color·attr·colorstatelist
恶猫20 小时前
SEELEN UI 桌面自定义工具 v2.3 介绍及安装教程, 深度美化win10/11,装机必备!!
ui·win11·win10·系统优化·桌面·桌面美化·桌面自定义
在路上看风景1 天前
15. 纹理尺寸是4的倍数
unity
星依网络1 天前
使用LabelImg工具标注数据(游戏辅助脚本开发)
python·游戏引擎·图形渲染·骨骼绑定
AT~1 天前
unity 使用Socket和protobuf实现网络连接
unity·游戏引擎
speedoooo1 天前
未来的App不再需要菜单栏?
前端·ui·容器·小程序·web app
weixin_446260851 天前
shadcn/ui - 打造个性化组件库的利器
ui
测试老哥1 天前
UI自动化测试—Jenkins配置优化
自动化测试·软件测试·python·测试工具·ui·jenkins·测试用例