Add Ribbon effect to Particles

This commit is contained in:
baz 2025-07-22 22:57:43 +01:00
parent e1b70b092d
commit 4fe6cc1281
7 changed files with 28 additions and 5 deletions

File diff suppressed because one or more lines are too long

BIN
Content/Weapons/DA_Projectile.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

View File

@ -5,6 +5,7 @@
#include "EnemyCharacter.h"
#include "HealthComponent.h"
#include "NiagaraComponent.h"
#include "ObjectPoolManager.h"
#include "ProjectileDataAsset.h"
#include "Components/SphereComponent.h"
@ -34,6 +35,10 @@ AProjectile::AProjectile()
StaticMeshComponent->SetEnableGravity(false);
StaticMeshComponent->SetGenerateOverlapEvents(false);
StaticMeshComponent->SetCollisionProfileName(TEXT("NoCollision"));
NiagaraRibbonComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("Niagara Ribbon Component"));
NiagaraRibbonComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
NiagaraRibbonComponent->DeactivateImmediate();
}
// Called when the game starts or when spawned
@ -70,6 +75,8 @@ void AProjectile::LoadDataFromDataAsset_Implementation(UProjectileDataAsset* pro
ProjectileMovement->InitialSpeed = ProjectileSpeed;
ProjectileMovement->MaxSpeed = ProjectileSpeed;
RemainingDamagableEnemies = projectileDataAsset->DamagableEnemies;
NiagaraRibbonComponent->SetAsset(projectileDataAsset->NiagaraRibbonSystem);
NiagaraRibbonComponent->ActivateSystem();
}
void AProjectile::ResetData_Implementation()
@ -77,6 +84,8 @@ void AProjectile::ResetData_Implementation()
ProjectileSpeed = NULL;
StaticMeshComponent->SetStaticMesh(nullptr);
RemainingDamagableEnemies = 1;
NiagaraRibbonComponent->DeactivateImmediate();
NiagaraRibbonComponent->SetAsset(nullptr);
}
void AProjectile::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
@ -106,7 +115,8 @@ void AProjectile::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedCompon
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
{
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
if (AObjectPoolManager* objectPoolManager =
IPools::Execute_GetProjectileObjectPoolManager(gamemode))
{
objectPoolManager->ReturnObject(this);
}

View File

@ -7,6 +7,7 @@
#include "Interfaces/Projectilable.h"
#include "Projectile.generated.h"
class UNiagaraComponent;
class UProjectileMovementComponent;
class USphereComponent;
class UProjectileDataAsset;
@ -34,6 +35,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int RemainingDamagableEnemies = 1;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<UNiagaraComponent> NiagaraRibbonComponent = nullptr;
// Sets default values for this actor's properties
AProjectile();

View File

@ -6,6 +6,7 @@
#include "Engine/DataAsset.h"
#include "ProjectileDataAsset.generated.h"
class UNiagaraSystem;
/**
*
*/
@ -23,4 +24,7 @@ public:
UPROPERTY(EditAnywhere)
int DamagableEnemies = 1;
UPROPERTY(EditAnywhere)
TObjectPtr<UNiagaraSystem> NiagaraRibbonSystem = nullptr;
};