diff --git a/Content/AnimStarterPack/Throw_Explosive_Montage.uasset b/Content/AnimStarterPack/Throw_Explosive_Montage.uasset index 159ef84..423467f 100644 --- a/Content/AnimStarterPack/Throw_Explosive_Montage.uasset +++ b/Content/AnimStarterPack/Throw_Explosive_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:026e2af33494e674741ebef5e013ccf893336260e30fa6399da215528380cf75 -size 11865 +oid sha256:f74e2c1ae24e74bb16dd79c5280699cf78c4459bbfbaaad6f99cbaf0d3d03d72 +size 13255 diff --git a/Content/AnimStarterPack/Throw_Weapon_Montage.uasset b/Content/AnimStarterPack/Throw_Weapon_Montage.uasset index d567def..d45579a 100644 --- a/Content/AnimStarterPack/Throw_Weapon_Montage.uasset +++ b/Content/AnimStarterPack/Throw_Weapon_Montage.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:055dcaa57ee637d4f4869cf32e6b2b1e7dae28f5f44f425bfc4473b553d55e89 -size 11847 +oid sha256:e91ad030f22d5e6fa902f66949f11b425e5acc8cb35a5d4dc69c78f25a38419a +size 14865 diff --git a/Source/Nakatomi/AnimNotify/NakatomiThrowEndNotify.cpp b/Source/Nakatomi/AnimNotify/NakatomiThrowEndNotify.cpp new file mode 100644 index 0000000..e22bc24 --- /dev/null +++ b/Source/Nakatomi/AnimNotify/NakatomiThrowEndNotify.cpp @@ -0,0 +1,16 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "../AnimNotify/NakatomiThrowEndNotify.h" + +#include "Nakatomi/PlayerCharacter.h" + +void UNakatomiThrowEndNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) +{ + APlayerCharacter* Character = Cast(MeshComp->GetOwner()); + + if (Character != nullptr) + { + Character->SetIsThrowing(false); + } +} diff --git a/Source/Nakatomi/AnimNotify/NakatomiThrowEndNotify.h b/Source/Nakatomi/AnimNotify/NakatomiThrowEndNotify.h new file mode 100644 index 0000000..e5380a9 --- /dev/null +++ b/Source/Nakatomi/AnimNotify/NakatomiThrowEndNotify.h @@ -0,0 +1,19 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Animation/AnimNotifies/AnimNotify.h" +#include "NakatomiThrowEndNotify.generated.h" + +/** + * + */ +UCLASS() +class NAKATOMI_API UNakatomiThrowEndNotify : public UAnimNotify +{ + GENERATED_BODY() + +public: + virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override; +}; diff --git a/Source/Nakatomi/AnimNotify/NakatomiThrowWeaponEndNotify.cpp b/Source/Nakatomi/AnimNotify/NakatomiThrowWeaponEndNotify.cpp new file mode 100644 index 0000000..3e205c5 --- /dev/null +++ b/Source/Nakatomi/AnimNotify/NakatomiThrowWeaponEndNotify.cpp @@ -0,0 +1,15 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "../AnimNotify/NakatomiThrowWeaponEndNotify.h" +#include "Nakatomi/PlayerCharacter.h" + +void UNakatomiThrowWeaponEndNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) +{ + APlayerCharacter* Character = Cast(MeshComp->GetOwner()); + + if (Character != nullptr) + { + Character->RemoveCurrentWeaponFromInventory(); + } +} diff --git a/Source/Nakatomi/AnimNotify/NakatomiThrowWeaponEndNotify.h b/Source/Nakatomi/AnimNotify/NakatomiThrowWeaponEndNotify.h new file mode 100644 index 0000000..f5f4679 --- /dev/null +++ b/Source/Nakatomi/AnimNotify/NakatomiThrowWeaponEndNotify.h @@ -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 "NakatomiThrowWeaponEndNotify.generated.h" + +/** + * + */ +UCLASS() +class NAKATOMI_API UNakatomiThrowWeaponEndNotify : public UAnimNotify +{ + GENERATED_BODY() + +public: + + virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override; +}; diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 2b4ef49..d1ea511 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -701,8 +701,9 @@ float APlayerCharacter::GetWeaponSpread() void APlayerCharacter::ThrowWeaponCallback() { - if (CurrentWeapon) + if (CurrentWeapon && !IsThrowing) { + IsThrowing = true; PlayAnimMontage(ThrowWeaponAnimMontage); } } @@ -723,14 +724,13 @@ void APlayerCharacter::ThrowWeapon() WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator); Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh()); - - RemoveCurrentWeaponFromInventory(); } void APlayerCharacter::ThrowExplosiveCallback() { if (ThrowableInventory.Num() > 0) { + IsThrowing = true; PlayAnimMontage(ThrowExplosiveAnimMontage); } } @@ -779,3 +779,13 @@ bool APlayerCharacter::GetCrouched() return false; } + +bool APlayerCharacter::GetIsThrowing() +{ + return IsThrowing; +} + +void APlayerCharacter::SetIsThrowing(bool bIsThrowing) +{ + IsThrowing = bIsThrowing; +} diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 801b8f7..690c7e2 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -141,6 +141,8 @@ private: USoundBase* HitMarkerSound; bool jumpPressed = false; + + bool IsThrowing = false; public: // Sets default values for this character's properties @@ -234,6 +236,12 @@ public: UFUNCTION(BlueprintCallable) bool GetCrouched(); + UFUNCTION(BlueprintCallable) + bool GetIsThrowing(); + + UFUNCTION(BlueprintCallable) + void SetIsThrowing(bool bIsThrowing); + protected: virtual void CalculateHits(TArray* hits) override;