diff --git a/Content/Input/Actions/IA_ThrowExplosive.uasset b/Content/Input/Actions/IA_ThrowExplosive.uasset new file mode 100644 index 0000000..92af8e5 --- /dev/null +++ b/Content/Input/Actions/IA_ThrowExplosive.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d7d59bf99019e0dc2b6c5dea267d15c31da0df3e3134e029cbeb9ca668f7e28 +size 1380 diff --git a/Content/Input/Actions/IA_ThrowWeapon.uasset b/Content/Input/Actions/IA_ThrowWeapon.uasset new file mode 100644 index 0000000..e281a6b --- /dev/null +++ b/Content/Input/Actions/IA_ThrowWeapon.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7579c7d582888cae07a0edeeb54c246a560bc2564e908c5baf5a8aebb96ee015 +size 1365 diff --git a/Content/Input/InputMappingContext.uasset b/Content/Input/InputMappingContext.uasset index 7c0bdff..0f95b6f 100644 --- a/Content/Input/InputMappingContext.uasset +++ b/Content/Input/InputMappingContext.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:44aeafcc8593edb9e19576b5d819779645dd7416b7f5bae84fe0c6ba6f207c10 -size 16965 +oid sha256:64250b131888a79dcf0cfbef950ed21f82258456aa2bb4e3afe7ae56f3c312b3 +size 18203 diff --git a/Content/Player/PlayerCharacter.uasset b/Content/Player/PlayerCharacter.uasset index 48def4b..bb83931 100644 --- a/Content/Player/PlayerCharacter.uasset +++ b/Content/Player/PlayerCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd5700e0af1f758f5449cf56c2faf50a9093d77b93352a17732a3a18033fb2b6 -size 37813 +oid sha256:aa2fdc4b10751572cb64a71389c82b8fafc20979a1aeed32654ff7ccf3fc5f78 +size 39607 diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index b2d6df6..5e4d8b0 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -13,7 +13,7 @@ #include "GameFramework/CharacterMovementComponent.h" #include "InputMappingContext.h" #include "EnemyCharacter.h" -#include "Throwable.h" + #define COLLISION_WEAPON ECC_GameTraceChannel1 @@ -171,9 +171,15 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom &APlayerCharacter::EndAimDownSightsCallback); } - if (ThrowAction) + if (ThrowWeaponAction) { - Input->BindAction(ThrowAction, ETriggerEvent::Started, this, &APlayerCharacter::ThrowThrowable); + Input->BindAction(ThrowWeaponAction, ETriggerEvent::Started, this, &APlayerCharacter::ThrowWeaponCallback); + } + + if (ThrowExplosiveAction) + { + Input->BindAction(ThrowExplosiveAction, ETriggerEvent::Started, this, + &APlayerCharacter::ThrowExplosiveCallback); } } } @@ -568,7 +574,25 @@ float APlayerCharacter::GetWeaponSpread() return CurrentWeapon->GetWeaponProperties()->WeaponSpread; } -void APlayerCharacter::ThrowThrowable() +void APlayerCharacter::ThrowWeaponCallback() +{ + auto throwable = ThrowThrowable(); + + + // TODO: Set the collision size to the size of the static mesh in the throwable + // throwable->GetSphereComponent()->SetSphereRadius(); +} + +void APlayerCharacter::ThrowExplosiveCallback() +{ + auto throwable = ThrowThrowable(); + + + // TODO: Set the collision size to the size of the static mesh in the throwable + // throwable->GetSphereComponent()->SetSphereRadius(); +} + +AThrowable* APlayerCharacter::ThrowThrowable() { FVector Location; FVector BoxExtent; @@ -576,8 +600,10 @@ void APlayerCharacter::ThrowThrowable() FVector SpawnLocation = FVector(Location.Z, Location.Y + (BoxExtent.Y / 2), Location.Z + (BoxExtent.Z / 2)); - AThrowable* Throwable = GetWorld()->SpawnActor(SpawnLocation, FRotator::ZeroRotator); + if (AThrowable* Throwable = GetWorld()->SpawnActor(SpawnLocation, FRotator::ZeroRotator)) + { + return Throwable; + } - // TODO: Set the collision size to the size of the static mesh in the throwable - //throwable->GetSphereComponent()->SetSphereRadius(); + return nullptr; } diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 9136645..635e8d5 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -14,6 +14,7 @@ #include "Blueprint/UserWidget.h" #include "Perception/AIPerceptionStimuliSourceComponent.h" #include "InteractableComponent.h" +#include "Throwable.h" #include "PlayerCharacter.generated.h" class UInputAction; @@ -49,8 +50,11 @@ public: UInputAction* SprintAction; UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - UInputAction* ThrowAction; + UInputAction* ThrowWeaponAction; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + UInputAction* ThrowExplosiveAction; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TSoftObjectPtr InputMappingContext; @@ -178,7 +182,11 @@ public: UFUNCTION(BlueprintCallable) float GetWeaponSpread(); - void ThrowThrowable(); + void ThrowWeaponCallback(); + + void ThrowExplosiveCallback(); + + AThrowable* ThrowThrowable(); protected: virtual void CalculateHits(TArray* hits) override;