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);

}

}

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

在角色类中变为

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

相关推荐
电子云与长程纠缠1 天前
UE5 Lyra PocketWorld进行3D内容UI预览 - 下
开发语言·学习·游戏·ui·ue5
远离UE42 天前
UE5 GPU内部异步
ue5
1204157137 肖哥2 天前
UE5 PCG PCGBlueprintElement简介
ue5
dong1326972 天前
UE5FPS游戏开发教程(四)
ue5
dong1326973 天前
UE5FPS游戏开发教程(三)
ue5
日月云棠3 天前
UE5源码分析之Editor——AnimationBlueprintLibrary模块全面分析
ue5
远离UE43 天前
UE5 ECS 原理
ue5
mengzhi啊5 天前
UE5 把剑绑定到骨骼-给要播放的动画及动画蒙太奇添加武器
ue5
directx3d_beginner5 天前
32,每帧更新怪物朝向改为c++
ue5
日月云棠5 天前
UE5源码分析之Editor——AnimationEditor模块全面分析
ue5