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

}

}

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

在角色类中变为

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

相关推荐
HAPPY酷9 小时前
【ROS2】 机械臂架构 vs UE5 游戏开发架构 终极对照表
架构·ue5
DoomGT10 小时前
UE5 - 制作游戏中切换窗口后游戏自动暂停功能
游戏·ue5·ue4·虚幻·虚幻引擎·unreal engine
远离UE44 天前
UE5 简单 Mesh Shader 制作流程
ue5
梦帮科技5 天前
UE5 GAS 实战:用 Gameplay Ability System 搭建「赛博修真」境界与技能体系
c++·人工智能·python·ue5·c#
远离UE45 天前
UE5 各类型灯光学习
学习·ue5
四代水门24 天前
UE5实现客户端与服务器时间同步
ue5
智海深蓝1 个月前
海上平行战场:态势模拟三维可视化平台
3d·ue5
_守一1 个月前
UE5 ListView记录
ue5
成都渲染101云渲染66661 个月前
CR15新功能介绍以及CR15云渲染流程
ue5·图形渲染·blender·maya·corona
一锅炖出任易仙1 个月前
创梦汤锅学习日记day30
学习·ai·ue5·游戏引擎