美文网首页
UE4使用c++播放BlendSpace1D

UE4使用c++播放BlendSpace1D

作者: 我真的不知道该起什么名字了 | 来源:发表于2019-04-22 20:04 被阅读0次

播放动作

    UBlendSpace1D *pBlendSpace = LoadObject<UBlendSpace1D>(nullptr, *montageName);
    UAnimInstance  *pAnimInstance = GetMesh()->GetAnimInstance();
    if (pBlendSpace && pAnimInstance) {
        bUpdateSpeed = true;
        GetMesh()->PlayAnimation(pBlendSpace, true);
        FVector BlendParams(GetVelocity().Size(), 0.f, 0.f);
        GetMesh()->GetSingleNodeInstance()->SetBlendSpaceInput(BlendParams);
    }

这里的blendSpace 的param类型是FVector, 在BlendSpace1D中,我们只用到了X轴方向的参数:


image.png

所以只设置x就可以了

还需要毎帧设置速度:

void AAnimCppCharacter::Tick(float DeltaSeconds)
{
    Super::Tick(DeltaSeconds);
    if (bUpdateSpeed) {
        FVector BlendParams(GetVelocity().Size(), 0.f, 0.f);
        GetMesh()->GetSingleNodeInstance()->SetBlendSpaceInput(BlendParams);
    }
}

相关文章

网友评论

      本文标题:UE4使用c++播放BlendSpace1D

      本文链接:https://www.haomeiwen.com/subject/sznugqtx.html