Add functionality to ThrowWeaponCallback

This commit is contained in:
baz 2023-09-18 02:28:31 +01:00
parent 81c954dabb
commit ff8e947a4e
1 changed files with 13 additions and 3 deletions

View File

@ -13,6 +13,7 @@
#include "GameFramework/CharacterMovementComponent.h" #include "GameFramework/CharacterMovementComponent.h"
#include "InputMappingContext.h" #include "InputMappingContext.h"
#include "EnemyCharacter.h" #include "EnemyCharacter.h"
#include "WeaponThrowable.h"
#define COLLISION_WEAPON ECC_GameTraceChannel1 #define COLLISION_WEAPON ECC_GameTraceChannel1
@ -576,11 +577,20 @@ float APlayerCharacter::GetWeaponSpread()
void APlayerCharacter::ThrowWeaponCallback() void APlayerCharacter::ThrowWeaponCallback()
{ {
auto throwable = ThrowThrowable(); FVector Location;
FVector BoxExtent;
GetActorBounds(true, Location, BoxExtent, false);
FVector SpawnLocation = FVector(Location.X, Location.Y + (BoxExtent.Y / 2), Location.Z + (BoxExtent.Z / 2));
SpawnLocation += GetTransform().GetLocation();
// TODO: Set the collision size to the size of the static mesh in the throwable if (TSubclassOf<AWeaponThrowable> WeaponThrowableTemplate = GetCurrentWeapon()->GetWeaponThrowableTemplate())
// throwable->GetSphereComponent()->SetSphereRadius(); {
AWeaponThrowable* Throwable = GetWorld()->SpawnActor<AWeaponThrowable>(
WeaponThrowableTemplate, SpawnLocation, FRotator::ZeroRotator);
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
}
} }
void APlayerCharacter::ThrowExplosiveCallback() void APlayerCharacter::ThrowExplosiveCallback()