Remove ability to throw while throwing animation is playing
This commit is contained in:
parent
fcb32e5679
commit
4930aff6c2
BIN
Content/AnimStarterPack/Throw_Explosive_Montage.uasset (Stored with Git LFS)
BIN
Content/AnimStarterPack/Throw_Explosive_Montage.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/AnimStarterPack/Throw_Weapon_Montage.uasset (Stored with Git LFS)
BIN
Content/AnimStarterPack/Throw_Weapon_Montage.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -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<APlayerCharacter>(MeshComp->GetOwner());
|
||||||
|
|
||||||
|
if (Character != nullptr)
|
||||||
|
{
|
||||||
|
Character->SetIsThrowing(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
};
|
|
@ -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<APlayerCharacter>(MeshComp->GetOwner());
|
||||||
|
|
||||||
|
if (Character != nullptr)
|
||||||
|
{
|
||||||
|
Character->RemoveCurrentWeaponFromInventory();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
};
|
|
@ -701,8 +701,9 @@ float APlayerCharacter::GetWeaponSpread()
|
||||||
|
|
||||||
void APlayerCharacter::ThrowWeaponCallback()
|
void APlayerCharacter::ThrowWeaponCallback()
|
||||||
{
|
{
|
||||||
if (CurrentWeapon)
|
if (CurrentWeapon && !IsThrowing)
|
||||||
{
|
{
|
||||||
|
IsThrowing = true;
|
||||||
PlayAnimMontage(ThrowWeaponAnimMontage);
|
PlayAnimMontage(ThrowWeaponAnimMontage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -723,14 +724,13 @@ void APlayerCharacter::ThrowWeapon()
|
||||||
WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator);
|
WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator);
|
||||||
|
|
||||||
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
|
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
|
||||||
|
|
||||||
RemoveCurrentWeaponFromInventory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::ThrowExplosiveCallback()
|
void APlayerCharacter::ThrowExplosiveCallback()
|
||||||
{
|
{
|
||||||
if (ThrowableInventory.Num() > 0)
|
if (ThrowableInventory.Num() > 0)
|
||||||
{
|
{
|
||||||
|
IsThrowing = true;
|
||||||
PlayAnimMontage(ThrowExplosiveAnimMontage);
|
PlayAnimMontage(ThrowExplosiveAnimMontage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -779,3 +779,13 @@ bool APlayerCharacter::GetCrouched()
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool APlayerCharacter::GetIsThrowing()
|
||||||
|
{
|
||||||
|
return IsThrowing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void APlayerCharacter::SetIsThrowing(bool bIsThrowing)
|
||||||
|
{
|
||||||
|
IsThrowing = bIsThrowing;
|
||||||
|
}
|
||||||
|
|
|
@ -142,6 +142,8 @@ private:
|
||||||
|
|
||||||
bool jumpPressed = false;
|
bool jumpPressed = false;
|
||||||
|
|
||||||
|
bool IsThrowing = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets default values for this character's properties
|
// Sets default values for this character's properties
|
||||||
APlayerCharacter(const FObjectInitializer& ObjectInitializer);
|
APlayerCharacter(const FObjectInitializer& ObjectInitializer);
|
||||||
|
@ -234,6 +236,12 @@ public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
bool GetCrouched();
|
bool GetCrouched();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
bool GetIsThrowing();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void SetIsThrowing(bool bIsThrowing);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue