150 - Spawning Grenades
This commit is contained in:
parent
d114ceb1fb
commit
5c1967bdaa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -315,6 +315,25 @@ void UCombatComponent::ThrowGrenadeFinished()
|
||||||
void UCombatComponent::LaunchGrenade()
|
void UCombatComponent::LaunchGrenade()
|
||||||
{
|
{
|
||||||
ShowAttachedGrenade(false);
|
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<AProjectile>(
|
||||||
|
GrenadeClass,
|
||||||
|
StartingLocation + 10.f,
|
||||||
|
ToTarget.Rotation(),
|
||||||
|
SpawnParams
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCombatComponent::OnRep_CombatState()
|
void UCombatComponent::OnRep_CombatState()
|
||||||
|
@ -362,7 +381,7 @@ int32 UCombatComponent::AmountToReload()
|
||||||
|
|
||||||
void UCombatComponent::ThrowGrenade()
|
void UCombatComponent::ThrowGrenade()
|
||||||
{
|
{
|
||||||
if (CombatState != ECombatState::ECS_Unoccupied) return;
|
if (CombatState != ECombatState::ECS_Unoccupied || EquippedWeapon == nullptr) return;
|
||||||
CombatState = ECombatState::ECS_ThrowingGrenade;
|
CombatState = ECombatState::ECS_ThrowingGrenade;
|
||||||
if (Character)
|
if (Character)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "Blaster/Types/CombatState.h"
|
#include "Blaster/Types/CombatState.h"
|
||||||
#include "Blaster/Weapon/WeaponTypes.h"
|
#include "Blaster/Weapon/WeaponTypes.h"
|
||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
|
#include "Blaster/Weapon/Projectile.h"
|
||||||
#include "CombatComponent.generated.h"
|
#include "CombatComponent.generated.h"
|
||||||
|
|
||||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||||
|
@ -71,6 +72,9 @@ protected:
|
||||||
UFUNCTION(Server, Reliable)
|
UFUNCTION(Server, Reliable)
|
||||||
void ServerThrowGrenade();
|
void ServerThrowGrenade();
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
TSubclassOf<class AProjectile> GrenadeClass;
|
||||||
|
|
||||||
void DropEquippedWeapon();
|
void DropEquippedWeapon();
|
||||||
void AttachActorToRightHand(AActor* ActorToAttach);
|
void AttachActorToRightHand(AActor* ActorToAttach);
|
||||||
void AttachActorToLeftHand(AActor* ActorToAttach);
|
void AttachActorToLeftHand(AActor* ActorToAttach);
|
||||||
|
|
|
@ -40,12 +40,12 @@ void AProjectileGrenade::OnBounce(const FHitResult& ImpactResult, const FVector&
|
||||||
if (InstigatorController)
|
if (InstigatorController)
|
||||||
{
|
{
|
||||||
UGameplayStatics::ApplyDamage(
|
UGameplayStatics::ApplyDamage(
|
||||||
BlasterCharacter,
|
BlasterCharacter,
|
||||||
Damage / 4,
|
Damage / 4,
|
||||||
InstigatorController,
|
InstigatorController,
|
||||||
this,
|
this,
|
||||||
UDamageType::StaticClass()
|
UDamageType::StaticClass()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue