【发布时间】:2017-10-31 22:57:05
【问题描述】:
在虚幻 4 中,我正在尝试为我们通过虚拟现实控制的 Pawn 播放枪的动画。我尝试在具有骨架网格的角色上制作相同的动画,一切都很好。现在我在一个具有相同骨架网格的 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);
}
请注意,所有内容都会编译,并且在执行代码时我没有任何错误
【问题讨论】:
-
我忘记放置 SlickBoyMotionControllerPawn.cpp 的构造函数,该构造函数包含获取对良好动画序列的引用以进行击退的代码,但它已经正常工作,我可以毫无问题地获得引用。跨度>
标签: c++ animation unreal-engine4