Add Gun Weapon

This commit is contained in:
baz 2024-07-31 15:27:45 +01:00
parent d9dba81c7e
commit 66a07e621d
3 changed files with 70 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,42 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GunWeapon.h"
AGunWeapon::AGunWeapon()
{
}
void AGunWeapon::BeginPlay()
{
Super::BeginPlay();
}
void AGunWeapon::FireWeaponAction_Implementation()
{
Super::FireWeaponAction_Implementation();
if (IsValid(ProjectileTemplate))
{
FActorSpawnParameters actorSpawnParameters;
actorSpawnParameters.Owner = this;
actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
AProjectile* projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(),
actorSpawnParameters);
projectile->TargetDirection = FVector(1.0f, 1.0f, 0.0f);
projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(),
actorSpawnParameters);
projectile->TargetDirection = FVector(-1.0f, 1.0f, 0.0f);
projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(),
actorSpawnParameters);
projectile->TargetDirection = FVector(1.0f, -1.0f, 0.0f);
projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(),
actorSpawnParameters);
projectile->TargetDirection = FVector(-1.0f, -1.0f, 0.0f);
}
}

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "ProjectileWeapon.h"
#include "GunWeapon.generated.h"
/**
*
*/
UCLASS()
class VAMPIRES_API AGunWeapon : public AProjectileWeapon
{
GENERATED_BODY()
public:
AGunWeapon();
protected:
virtual void BeginPlay() override;
public:
virtual void FireWeaponAction_Implementation() override;
};