Projectiles C++ API
Class: ABaseProjectile — Source/LesDeuxPelos/Public/Projectiles/BaseProjectile.h
Inherits: AActor
Overview
A projectile is an Actor spawned by a Passive. It moves via UProjectileMovementComponent, handles collision via USphereComponent, and applies damage and buffs on hit.
Components
| Component | Type | Description |
|---|---|---|
ArrowComponent | UArrowComponent | Editor-only forward direction indicator. |
ProjectileMesh | UStaticMeshComponent | Visual mesh. Set No Collision on this component — use CollisionComponent for hit detection. |
CollisionComponent | USphereComponent | Collision sphere. Enable Overlap events on the relevant channels. |
ProjectileMovementComponent | UProjectileMovementComponent | Handles velocity, homing, gravity. |
Properties
Movement
| Property | Type | Description |
|---|---|---|
InitialSpeed | float | Initial speed (units/s). Set to 0 when parented to owner. |
Level-based arrays
One entry per upgrade level (levels 1–5, 0-indexed).
| Property | Type | Description |
|---|---|---|
OnHitDamage | TArray<int> | Damage per hit per level. |
Range | TArray<float> | Max travel distance before auto-destroy. Empty = infinite. |
DurationBeforeDestroy | TArray<float> | Lifetime in seconds. Empty = no time limit. |
Hit behavior
| Property | Type | Default | Description |
|---|---|---|---|
DestroyOnHit | bool | true | Destroy the projectile on first overlap. |
SpawnedActorsOnHit | TArray<TSubclassOf<AActor>> | — | Actors to spawn at hit location (per level). |
Buffs on hit
| Property | Type | Default | Description |
|---|---|---|---|
ApplyBuffsOnHit | bool | false | Enable buff application on hit. |
OnHitBuffs | TArray<FBuffArray> | — | Array of buff lists per level. FBuffArray wraps TArray<TSubclassOf<UBaseBuff>>. |
Runtime state (read-only)
| Field | Type | Description |
|---|---|---|
SourcePassive | TObjectPtr<UBasePassive> | The passive that spawned this projectile. |
HomingTargetActor | TObjectPtr<ALesDeuxPelosCharacter> | Active homing target. |
ProjectileLevel | int | Level set by the spawning passive. |
Blueprint events
| Event | Description |
|---|---|
OnHitEffect(OtherActor) | BlueprintImplementableEvent — override for visual/sound effects on hit. Do not destroy here, C++ handles it. |
Methods
| Method | Access | Description |
|---|---|---|
DestroyProjectile() | BlueprintCallable | Manually destroy the projectile. |
SetSourcePassive(InSourcePassive) | public | Called by the spawning passive at creation. |
NotifyActorBeginOverlap(OtherActor) | protected virtual | Handles damage, buff application, and destruction on overlap. |
Structs
FBuffArray
cpp
USTRUCT(BlueprintType)
struct FBuffArray {
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSubclassOf<UBaseBuff>> Buffs;
};Used to represent a list of buffs for one level in OnHitBuffs.
Blueprint usage
Create a Blueprint child of ABaseProjectile. See Create a Projectile.