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;
相关推荐
ysn111112 小时前
搭建状态同步框架的实践心得
unity·架构
烛衔溟3 小时前
HarmonyOS 基础 UI 构建 —— 组件、布局与沉浸式效果
ui·华为·harmonyos
一线灵4 小时前
Axmol:小众引擎的硬核逆袭
游戏引擎
一次旅行4 小时前
CopilotKit实战:用生成式UI打造智能Agent前端
前端·人工智能·ui
weixin_441940015 小时前
【Unity教程】使用vuforia创建简单的AR实例
unity·游戏引擎·ar
郝学胜-神的一滴5 小时前
[简化版 GAMES 101] 计算机图形学 12:可见性与 Z‑Buffer 深度缓存
unity·godot·图形渲染·three.js·opengl·unreal
归真仙人15 小时前
【UE】LineTraceByProfile
ue5·游戏引擎·ue4·unreal engine
gqk0117 小时前
Delegate.Target/ Method
前端·ui·xhtml
李二。17 小时前
ArkTS原生 | 知识问答引擎 —— 鸿蒙Next声明式UI实战
ui·华为·harmonyos
陈葛杰19 小时前
PS2026安装教程
ui·photoshop