diff --git a/Content/Assets/Animations/GrenadeToss.uasset b/Content/Assets/Animations/GrenadeToss.uasset index 35b725e..d4236d9 100644 Binary files a/Content/Assets/Animations/GrenadeToss.uasset and b/Content/Assets/Animations/GrenadeToss.uasset differ diff --git a/Content/Assets/FPS_Weapon_Bundle/Weapons/Materials/G67_Grenade/M_G67.uasset b/Content/Assets/FPS_Weapon_Bundle/Weapons/Materials/G67_Grenade/M_G67.uasset index 44f8c2c..3f10da6 100644 Binary files a/Content/Assets/FPS_Weapon_Bundle/Weapons/Materials/G67_Grenade/M_G67.uasset and b/Content/Assets/FPS_Weapon_Bundle/Weapons/Materials/G67_Grenade/M_G67.uasset differ diff --git a/Content/Assets/FPS_Weapon_Bundle/Weapons/Meshes/G67_Grenade/SM_G67_Thrown.uasset b/Content/Assets/FPS_Weapon_Bundle/Weapons/Meshes/G67_Grenade/SM_G67_Thrown.uasset index ab154dd..52bebec 100644 Binary files a/Content/Assets/FPS_Weapon_Bundle/Weapons/Meshes/G67_Grenade/SM_G67_Thrown.uasset and b/Content/Assets/FPS_Weapon_Bundle/Weapons/Meshes/G67_Grenade/SM_G67_Thrown.uasset differ diff --git a/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset b/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset index faada01..76e8702 100644 Binary files a/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset and b/Content/Assets/LearningKit_Games/Assets/Characters/Character/Mesh/SK_EpicCharacter_Skeleton.uasset differ diff --git a/Content/Blueprints/Character/BP_BlasterCharacter.uasset b/Content/Blueprints/Character/BP_BlasterCharacter.uasset index a9124df..5176dcc 100644 Binary files a/Content/Blueprints/Character/BP_BlasterCharacter.uasset and b/Content/Blueprints/Character/BP_BlasterCharacter.uasset differ diff --git a/Content/Blueprints/Weapon/Projectiles/BP_Grenade.uasset b/Content/Blueprints/Weapon/Projectiles/BP_Grenade.uasset new file mode 100644 index 0000000..41ae80f Binary files /dev/null and b/Content/Blueprints/Weapon/Projectiles/BP_Grenade.uasset differ diff --git a/Content/Blueprints/Weapon/Projectiles/BP_ProjectileGrenade.uasset b/Content/Blueprints/Weapon/Projectiles/BP_ProjectileGrenade.uasset index 57073de..12dbc23 100644 Binary files a/Content/Blueprints/Weapon/Projectiles/BP_ProjectileGrenade.uasset and b/Content/Blueprints/Weapon/Projectiles/BP_ProjectileGrenade.uasset differ diff --git a/Source/Blaster/Components/CombatComponent.cpp b/Source/Blaster/Components/CombatComponent.cpp index c50e379..97ecd49 100644 --- a/Source/Blaster/Components/CombatComponent.cpp +++ b/Source/Blaster/Components/CombatComponent.cpp @@ -315,6 +315,25 @@ void UCombatComponent::ThrowGrenadeFinished() void UCombatComponent::LaunchGrenade() { ShowAttachedGrenade(false); + if (Character && Character->HasAuthority() && GrenadeClass && Character->GetAttachedGrenade()) + { + const FVector StartingLocation = Character->GetAttachedGrenade()->GetComponentLocation(); + FVector ToTarget = HitTarget - StartingLocation; + FActorSpawnParameters SpawnParams; + SpawnParams.Owner = Character; + SpawnParams.Instigator = Character; + + UWorld* World = GetWorld(); + if (World) + { + World->SpawnActor( + GrenadeClass, + StartingLocation + 10.f, + ToTarget.Rotation(), + SpawnParams + ); + } + } } void UCombatComponent::OnRep_CombatState() @@ -362,7 +381,7 @@ int32 UCombatComponent::AmountToReload() void UCombatComponent::ThrowGrenade() { - if (CombatState != ECombatState::ECS_Unoccupied) return; + if (CombatState != ECombatState::ECS_Unoccupied || EquippedWeapon == nullptr) return; CombatState = ECombatState::ECS_ThrowingGrenade; if (Character) { diff --git a/Source/Blaster/Components/CombatComponent.h b/Source/Blaster/Components/CombatComponent.h index 359f54f..b75f767 100644 --- a/Source/Blaster/Components/CombatComponent.h +++ b/Source/Blaster/Components/CombatComponent.h @@ -7,6 +7,7 @@ #include "Blaster/Types/CombatState.h" #include "Blaster/Weapon/WeaponTypes.h" #include "Components/ActorComponent.h" +#include "Blaster/Weapon/Projectile.h" #include "CombatComponent.generated.h" UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) @@ -71,6 +72,9 @@ protected: UFUNCTION(Server, Reliable) void ServerThrowGrenade(); + UPROPERTY(EditAnywhere) + TSubclassOf GrenadeClass; + void DropEquippedWeapon(); void AttachActorToRightHand(AActor* ActorToAttach); void AttachActorToLeftHand(AActor* ActorToAttach); diff --git a/Source/Blaster/Weapon/ProjectileGrenade.cpp b/Source/Blaster/Weapon/ProjectileGrenade.cpp index 23c5f27..c5d4c38 100644 --- a/Source/Blaster/Weapon/ProjectileGrenade.cpp +++ b/Source/Blaster/Weapon/ProjectileGrenade.cpp @@ -40,12 +40,12 @@ void AProjectileGrenade::OnBounce(const FHitResult& ImpactResult, const FVector& if (InstigatorController) { UGameplayStatics::ApplyDamage( - BlasterCharacter, - Damage / 4, - InstigatorController, - this, - UDamageType::StaticClass() - ); + BlasterCharacter, + Damage / 4, + InstigatorController, + this, + UDamageType::StaticClass() + ); } } }