DEV Community

Liquefier
Liquefier

Posted on

Unreal C++ Course Chapter 114 - 115.

Very straight forward blueprint and C++ use of attack montages, I also included a check to see if the character state was unequipped, which looks like it will be the next lesson. (I tend to get ahead of myself)


void AEchoCharacter::EchoAttack()
{
    UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
    if (AnimInstance && AttackMontage && CurrentEquipState != ECharacterEquipState::ECS_UnEquipped)
    {
        AnimInstance->Montage_Play(AttackMontage);
        int32 selection = FMath::RandRange(0, 1);

        switch (selection)
        {
        case 0:
            AnimInstance->Montage_JumpToSection("Attack1", AttackMontage);
            break;
        case 1:
            AnimInstance->Montage_JumpToSection("Attack2", AttackMontage);
            break;
        }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)