You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Character BP详情面板暴露Animation BP的MyVar变量?

实现Animation蓝图变量在Character蓝图Details面板直接编辑

蓝图方案(无需代码)

  • 打开你的Animation Blueprint,找到变量MyVar,在变量的Details面板里勾选Editable和Expose on Spawn两个选项。
  • 回到Character Blueprint,在Components面板选中绑定的Animation Instance组件(一般是Mesh组件下的Anim Instance)。
  • 此时在Character的Details面板里,找到Anim Instance分组,展开后就能直接看到MyVar,可以直接编辑数值。如果没显示,右键Animation组件选择Refresh Details刷新即可。

C++方案(适合多变量场景)

如果变量数量多,用C++定义基类会更高效:

  1. 创建继承自UAnimInstance的C++类(例如UMyCustomAnimInstance),在头文件中声明可编辑变量:
UCLASS(Blueprintable, BlueprintType)
class YOURPROJECT_API UMyCustomAnimInstance : public UAnimInstance
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Custom Anim Vars")
    float MyVar;

    // 可批量添加更多变量
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Custom Anim Vars")
    bool bIsRunning;
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Custom Anim Vars")
    FVector MoveDirection;
};
  1. 打开你的Animation Blueprint,在Class Settings里将父类切换为刚才创建的UMyCustomAnimInstance。
  2. 回到Character Blueprint,选中Animation Instance组件后,Details面板会自动出现Custom Anim Vars分组,所有声明的变量都能直接编辑,不用在Character里重复复制变量。

注意事项

  • 蓝图变量必须同时开启Editable和Expose on Spawn才会在Character的Details面板显示。
  • C++变量的UPROPERTY必须包含EditAnywhere或EditInstanceOnly属性,否则无法在Details面板编辑。

内容的提问来源于stack exchange,提问作者Manas R. Makde

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 23:50:58