Add Fire Wand Weapon
This commit is contained in:
parent
b054db1478
commit
b8f08e83cc
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue