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;
相关推荐
Howrun7777 小时前
虚幻引擎_创建组件
游戏引擎·虚幻
Jessica巨人7 小时前
pico相关插件介绍
unity
leo__5207 小时前
基于模糊控制的MATLAB避障算法实现
算法·matlab·unity
世人万千丶7 小时前
鸿蒙跨端框架 Flutter 学习:GetX 全家桶:从状态管理到路由导航的极简艺术
学习·flutter·ui·华为·harmonyos·鸿蒙
闻缺陷则喜何志丹7 小时前
【C# WPF】TextBox的数据绑定
ui·c#·wpf·mvvm·数据绑定·textbox
wtsolutions1 天前
Understanding Excel Data Formats - What Excel to JSON Supports
ui·json·excel
WinstonJQ1 天前
AirSim无人机仿真入门(一):实现无人机的起飞与降落
python·机器人·游戏引擎·ue4·无人机
da_vinci_x1 天前
图标量产:从“手绘地狱”到“风格克隆”?Style Reference 的工业化实战
前端·游戏·ui·prompt·aigc·设计师·游戏美术
wtsolutions1 天前
Using the Excel to JSON API - Programmatic Access for Developers
ui·json·xhtml