Add Fire Wand Weapon

This commit is contained in:
baz 2024-07-31 14:31:29 +01:00
parent b054db1478
commit b8f08e83cc
3 changed files with 65 additions and 0 deletions

BIN
Content/Weapons/FireWand/BP_FireWandWeapon.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "FireWandWeapon.h"
#include "Kismet/KismetMathLibrary.h"
AFireWandWeapon::AFireWandWeapon()
{
}
void AFireWandWeapon::BeginPlay()
{
Super::BeginPlay();
}
void AFireWandWeapon::FireWeaponAction_Implementation()
{
if (IsValid(ProjectileTemplate) && OverlappedEnemies.Num() > 0)
{
FActorSpawnParameters actorSpawnParameters;
actorSpawnParameters.Owner = this;
actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
AProjectile* projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(),
actorSpawnParameters);
AActor* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)];
FVector direction = UKismetMathLibrary::GetDirectionUnitVector(
GetActorLocation(), target->GetActorLocation());
direction.Z = 0.0;
direction.Normalize();
projectile->TargetDirection = direction;
}
}

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 "FireWandWeapon.generated.h"
/**
*
*/
UCLASS()
class VAMPIRES_API AFireWandWeapon : public AProjectileWeapon
{
GENERATED_BODY()
public:
AFireWandWeapon();
protected:
virtual void BeginPlay() override;
public:
virtual void FireWeaponAction_Implementation() override;
};