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()
|
||||
{
|
||||
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()
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<class AProjectile> GrenadeClass;
|
||||
|
||||
void DropEquippedWeapon();
|
||||
void AttachActorToRightHand(AActor* ActorToAttach);
|
||||
void AttachActorToLeftHand(AActor* ActorToAttach);
|
||||
|
|
Loading…
Reference in New Issue