5,动画蓝图类接口转c++

蓝图中有个动画接口类传递连击index和角色是否在攻击,确定播放哪个攻击动画,

这里也改成C++

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"

#include "UObject/Interface.h"

#include "BPI_Anims.generated.h"

// This class does not need to be modified.

UINTERFACE(MinimalAPI)

class UBPI_Anims : public UInterface

{

GENERATED_BODY()

};

/**

*

*/

class ROUGHLIKE1_API IBPI_Anims

{

GENERATED_BODY()

复制代码
// Add interface functions to this class. This is the class that will be inherited to implement this interface.

public:

UFUNCTION(BlueprintNativeEvent, BlueprintCallable,Category = "Anim Interface")

void INT_SetAttacks(int32 comboIndex, bool IsAttacking);

};

在角色类添加

public:

//调用攻击动画接口类

UFUNCTION(BlueprintCallable, Category = "Animation")

void SetAnimAttack(int32 comboIndex, bool bIsAttacking);

void AMyPaperZDCharacter::SetAnimAttack(int32 comboIndex, bool bIsAttacking)

{

//获取动画组件

UPaperZDAnimationComponent* animComp = GetAnimationComponent();

if (!animComp)

{

return;

}

//获取动画实例

UPaperZDAnimInstance* animInstance = animComp->GetAnimInstance();

if (!animInstance)

{

return;

}

//检查是否实现接口

if (animInstance->Implements<UBPI_Anims>())

{

IBPI_Anims::Execute_INT_SetAttacks(animInstance, comboIndex, bIsAttacking);

}

}

改后,把以前的蓝图接口类删除,

在角色类中变为

动画蓝图类中替换为新接口,

相关推荐
远离UE42 天前
UE5 Substrate Thin Film 源码拆析
开发语言·javascript·ue5
七仔啊3 天前
UE5源码下载及编译
ue5
Zhichao_973 天前
【UE5.8 MCP】接入AI大模型
ue5
曼巴UE55 天前
UE 属性同步
网络·c++·ue5
易知微EasyV数据可视化6 天前
UE5中添加 PNG/TIF 到 Cesium 地球表面方案
经验分享·ue5·数字孪生
GR906 天前
UE5 SetActorLocation背后发生了什么
ue5
成都渲染101云渲染66668 天前
云渲染怎么用?从项目准备到提交出图,3ds Max、VRay、UE5 实用教程
3d·ue5
directx3d_beginner10 天前
42,将移向指定位置改为c++
ue5
ue星空13 天前
UE5放了playstart显示badsize解决方案
ue5
directx3d_beginner15 天前
41,从UE5.1迁移到UE5.8排坑全记录
ue5