如何在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++定义基类会更高效:
- 创建继承自
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; };
- 打开你的Animation Blueprint,在Class Settings里将父类切换为刚才创建的
UMyCustomAnimInstance。 - 回到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
相关产品推荐
相关产品推荐

