Compare commits
3 Commits
d96a5c837a
...
fcb32e5679
Author | SHA1 | Date |
---|---|---|
baz | fcb32e5679 | |
baz | aef9f87dbf | |
baz | eaa81f4478 |
Binary file not shown.
BIN
Content/AnimStarterPack/Throw_Montage.uasset (Stored with Git LFS)
BIN
Content/AnimStarterPack/Throw_Montage.uasset (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)
BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -0,0 +1,15 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "../AnimNotify/NakatomiThrowExplosiveNotify.h"
|
||||||
|
#include "Nakatomi/PlayerCharacter.h"
|
||||||
|
|
||||||
|
void UNakatomiThrowExplosiveNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
|
||||||
|
{
|
||||||
|
APlayerCharacter* Character = Cast<APlayerCharacter>(MeshComp->GetOwner());
|
||||||
|
|
||||||
|
if (Character != nullptr)
|
||||||
|
{
|
||||||
|
Character->ThrowExplosive();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Animation/AnimNotifies/AnimNotify.h"
|
||||||
|
#include "NakatomiThrowExplosiveNotify.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API UNakatomiThrowExplosiveNotify : public UAnimNotify
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;
|
||||||
|
|
||||||
|
};
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
};
|
|
@ -703,46 +703,52 @@ void APlayerCharacter::ThrowWeaponCallback()
|
||||||
{
|
{
|
||||||
if (CurrentWeapon)
|
if (CurrentWeapon)
|
||||||
{
|
{
|
||||||
PlayAnimMontage(ThrowAnimMontage);
|
PlayAnimMontage(ThrowWeaponAnimMontage);
|
||||||
|
|
||||||
FVector Location;
|
|
||||||
FVector BoxExtent;
|
|
||||||
GetActorBounds(true, Location, BoxExtent, false);
|
|
||||||
|
|
||||||
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
|
||||||
SpawnLocation += Location;
|
|
||||||
SpawnLocation.Z += BoxExtent.Z;
|
|
||||||
|
|
||||||
TSubclassOf<AWeaponThrowable> WeaponThrowableTemplate = CurrentWeapon->GetWeaponThrowableTemplate();
|
|
||||||
|
|
||||||
AWeaponThrowable* Throwable = GetWorld()->SpawnActor<AWeaponThrowable>(
|
|
||||||
WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator);
|
|
||||||
|
|
||||||
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
|
|
||||||
|
|
||||||
RemoveCurrentWeaponFromInventory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APlayerCharacter::ThrowWeapon()
|
||||||
|
{
|
||||||
|
FVector Location;
|
||||||
|
FVector BoxExtent;
|
||||||
|
GetActorBounds(true, Location, BoxExtent, false);
|
||||||
|
|
||||||
|
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
||||||
|
SpawnLocation += Location;
|
||||||
|
SpawnLocation.Z += BoxExtent.Z;
|
||||||
|
|
||||||
|
TSubclassOf<AWeaponThrowable> WeaponThrowableTemplate = CurrentWeapon->GetWeaponThrowableTemplate();
|
||||||
|
|
||||||
|
AWeaponThrowable* Throwable = GetWorld()->SpawnActor<AWeaponThrowable>(
|
||||||
|
WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator);
|
||||||
|
|
||||||
|
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
|
||||||
|
|
||||||
|
RemoveCurrentWeaponFromInventory();
|
||||||
|
}
|
||||||
|
|
||||||
void APlayerCharacter::ThrowExplosiveCallback()
|
void APlayerCharacter::ThrowExplosiveCallback()
|
||||||
{
|
{
|
||||||
if (ThrowableInventory.Num() > 0)
|
if (ThrowableInventory.Num() > 0)
|
||||||
{
|
{
|
||||||
PlayAnimMontage(ThrowAnimMontage);
|
PlayAnimMontage(ThrowExplosiveAnimMontage);
|
||||||
|
|
||||||
FVector Location;
|
|
||||||
FVector BoxExtent;
|
|
||||||
GetActorBounds(true, Location, BoxExtent, false);
|
|
||||||
|
|
||||||
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
|
||||||
SpawnLocation += Location;
|
|
||||||
SpawnLocation += (25.0f * GetActorForwardVector());
|
|
||||||
SpawnLocation.Z += BoxExtent.Z;
|
|
||||||
|
|
||||||
GetWorld()->SpawnActor<AThrowable>(ThrowableInventory.Pop(), SpawnLocation, FRotator::ZeroRotator);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APlayerCharacter::ThrowExplosive()
|
||||||
|
{
|
||||||
|
FVector Location;
|
||||||
|
FVector BoxExtent;
|
||||||
|
GetActorBounds(true, Location, BoxExtent, false);
|
||||||
|
|
||||||
|
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
||||||
|
SpawnLocation += Location;
|
||||||
|
SpawnLocation += (25.0f * GetActorForwardVector());
|
||||||
|
SpawnLocation.Z += BoxExtent.Z;
|
||||||
|
|
||||||
|
GetWorld()->SpawnActor<AThrowable>(ThrowableInventory.Pop(), SpawnLocation, FRotator::ZeroRotator);
|
||||||
|
}
|
||||||
|
|
||||||
AThrowable* APlayerCharacter::ThrowThrowable()
|
AThrowable* APlayerCharacter::ThrowThrowable()
|
||||||
{
|
{
|
||||||
FVector Location;
|
FVector Location;
|
||||||
|
|
|
@ -84,7 +84,10 @@ public:
|
||||||
FOnEnemyHitDelegate OnEnemyHit;
|
FOnEnemyHitDelegate OnEnemyHit;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
UAnimMontage* ThrowAnimMontage;
|
UAnimMontage* ThrowWeaponAnimMontage;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
UAnimMontage* ThrowExplosiveAnimMontage;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
@ -217,8 +220,12 @@ public:
|
||||||
|
|
||||||
void ThrowWeaponCallback();
|
void ThrowWeaponCallback();
|
||||||
|
|
||||||
|
void ThrowWeapon();
|
||||||
|
|
||||||
void ThrowExplosiveCallback();
|
void ThrowExplosiveCallback();
|
||||||
|
|
||||||
|
void ThrowExplosive();
|
||||||
|
|
||||||
AThrowable* ThrowThrowable();
|
AThrowable* ThrowThrowable();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
|
|
Loading…
Reference in New Issue