在虚幻 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/