按键事件触发播放翻滚蒙太奇,调整姿态,是蹲伏还是站立。如果是站立需要蹲下再翻再起来
void ACwlAlsCharacterBase::OnRoll()
{
GetMyAnimInstance()->Montage_Play(GetRollMontage(), 1.13f);
if (GetCurStance() == ECwlAlsStance::Standing)
{
DesiredStance = ECwlAlsStance::Standing;
}
else if (GetCurStance() == ECwlAlsStance::Crouch)
{
DesiredStance = ECwlAlsStance::Crouch;
}
}
翻滚动作的动画蒙太奇添加动画通知
void UCwlAlsNotifyStateMovementAction::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration)
{
Super::NotifyBegin(MeshComp, Animation, TotalDuration);
ACwlAlsCharacterBase* BaseCharacter = Cast<ACwlAlsCharacterBase>(MeshComp->GetOwner());
if (BaseCharacter)
{
BaseCharacter->SetMovementAction(MovementAction);
}
}
void UCwlAlsNotifyStateMovementAction::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
Super::NotifyEnd(MeshComp, Animation);
ACwlAlsCharacterBase* BaseCharacter = Cast<ACwlAlsCharacterBase>(MeshComp->GetOwner());
if (BaseCharacter && BaseCharacter->GetCurMovementAction() == MovementAction)
{
BaseCharacter->SetMovementAction(ECwlAlsMovementAction::None);
}
}
在动画通知的开始和结束set movement action
注意这两个地方有个进入事件 stop transition
同时补充逻辑
void UCwlAlsCharacterAnimInstance::StopTransition()
{
StopSlotAnimation(0.2, GName_Ground_Slot);
StopSlotAnimation(0.2, TEXT("(N) Turn/Rotate"));
StopSlotAnimation(0.2, TEXT("(CLF) Turn/Rotate"));
}
这里加一个事件