我创建了三个BindAction的按键。
[mw_shl_code=cpp,true] InputComponent->BindAction("DunForWard", IE_Pressed, this, &AOneCharacter:unForWard);
InputComponent->BindAction("DunRight", IE_Pressed, this, &AOneCharacter:unRight);
InputComponent->BindAction("DunLeft", IE_Pressed, this, &AOneCharacter:unLeft);[/mw_shl_code]
然后是用播放蒙太奇来实现动画的
[mw_shl_code=applescript,true]//Play DunForWard Montage
void AOneCharacter:unForWard()
{
if (DunForWardMontage != NULL)
{
UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
if (AnimInstance != NULL)
{
AnimInstance->Montage_Play(DunForWardMontage, 1.0f);
}
}
}
//Play DunRight Montage
void AOneCharacter:unRight()
{
if (DunRightMontage != NULL)
{
UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
if (AnimInstance != NULL)
{
AnimInstance->Montage_Play(DunRightMontage, 1.0f);
}
}
}
//Play DunLeft Montage
void AOneCharacter:unLeft()
{
if (DunLeftMontage != NULL)
{
UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
if (AnimInstance != NULL)
{
AnimInstance->Montage_Play(DunRightMontage, 1.0f);
}
}
}
[/mw_shl_code]
可是,播放的时候我发现蒙太奇视频有点长。停止按键之后,人物不会立马就停止动作
我试过使用IE_Releasrd,可是,我不知道要如何判断按键为假。
请问怎么样才能让它一停止按键,就会停止播放蒙太奇呢?
还有。请问如何才能用C++自定义一个按键和按键组合呢?
|