Add Throw Weapon Animation Notifier

This commit is contained in:
baz 2024-02-01 20:08:00 +00:00
parent d96a5c837a
commit eaa81f4478
4 changed files with 60 additions and 19 deletions

View File

@ -0,0 +1,16 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "../AnimNotify/NakatomiThrowWeaponNotify.h"
#include "Nakatomi/PlayerCharacter.h"
void UNakatomiThrowWeaponNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
APlayerCharacter* Character = Cast<APlayerCharacter>(MeshComp->GetOwner());
if (Character != nullptr)
{
Character->ThrowWeapon();
}
}

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Animation/AnimNotifies/AnimNotify.h"
#include "NakatomiThrowWeaponNotify.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UNakatomiThrowWeaponNotify : public UAnimNotify
{
GENERATED_BODY()
public:
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;
};

View File

@ -703,8 +703,12 @@ void APlayerCharacter::ThrowWeaponCallback()
{ {
if (CurrentWeapon) if (CurrentWeapon)
{ {
PlayAnimMontage(ThrowAnimMontage); PlayAnimMontage(ThrowWeaponAnimMontage);
}
}
void APlayerCharacter::ThrowWeapon()
{
FVector Location; FVector Location;
FVector BoxExtent; FVector BoxExtent;
GetActorBounds(true, Location, BoxExtent, false); GetActorBounds(true, Location, BoxExtent, false);
@ -721,7 +725,6 @@ void APlayerCharacter::ThrowWeaponCallback()
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh()); Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
RemoveCurrentWeaponFromInventory(); RemoveCurrentWeaponFromInventory();
}
} }
void APlayerCharacter::ThrowExplosiveCallback() void APlayerCharacter::ThrowExplosiveCallback()

View File

@ -84,7 +84,7 @@ public:
FOnEnemyHitDelegate OnEnemyHit; FOnEnemyHitDelegate OnEnemyHit;
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
UAnimMontage* ThrowAnimMontage; UAnimMontage* ThrowWeaponAnimMontage;
protected: protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
@ -217,6 +217,8 @@ public:
void ThrowWeaponCallback(); void ThrowWeaponCallback();
void ThrowWeapon();
void ThrowExplosiveCallback(); void ThrowExplosiveCallback();
AThrowable* ThrowThrowable(); AThrowable* ThrowThrowable();