c++ - 在 Pawn 的骨架网格物体上播放动画

标签 c++ animation unreal-engine4

在虚幻 4 中,我正在尝试通过我们通过虚拟现实控制的 Pawn 为 Gun 播放动画。我尝试在具有骨架网格物体的角色上制作相同的动画,一切顺利。现在我在一个具有相同骨架网格物体的 Pawn 中,但没有播放动画。

SlickBoyMotionControllerPawn.cpp

// Function where I trigger the animation
void ASlickBoyMotionControllerPawn::Fire(ASlickBoyMotionController *Current)
{
        // Rest of the code that handle the fire of the gun

        // Current is the gun that fires (motion control)
        USkeletalMeshComponent* currentMesh = Current->GetHandMesh();
        if (currentMesh) {
            currentMesh->PlayAnimation(knockBack, false);
            currentMesh->PlayAnimation(trigger, false);
        }
}

SlickBoyMotionControllerPawn.h

UCLASS()
class SLICKBOY_API ASlickBoyMotionControllerPawn : public APawn, public IAttackable
{
    GENERATED_BODY()
public:
    // other stuff

    // Gun Anim
    UAnimSequence *knockBack;
    UAnimSequence *trigger;

    UFUNCTION()
    void Fire(class ASlickBoyMotionController* Hand);
}

请注意,所有内容都可以编译,并且我在执行代码时没有任何错误

最佳答案

knockback 序列不会播放,因为您立即用 trigger 覆盖了动画。

currentMesh->PlayAnimation(knockBack, false);
currentMesh->PlayAnimation(trigger, false);

PlayAnimation 是一个非阻塞调用,代码不会等到 knockback 播放完毕才开始 trigger

如果你想连续播放两个动画,使用Animation Composite

关于c++ - 在 Pawn 的骨架网格物体上播放动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47045704/

相关文章:

c++ - 哪些 C++ 编译器已经支持 lambda?

c++ - 使用模板传递时访问 vector 元素

c++ - 虚幻引擎 C++ SpawnActor 类型转换

c++ - 如何在 C++ 中从 UTexture2D 读取数据

C++ 访问冲突类数组

c++ - 重载运算符中的段错误 =

javascript - 每个动画的 react 运动渲染

swift - 自定义幻灯片转场 - Xcode 8.0 Swift 3.0

css - 动画 svg 不适用于边缘/IE

c++ - 如何在客户端获取 GameplayAbility 属性的增量值(属性值更改后)?