Ranged

Module PulseCombatRanged (depends on PulseCombat). A ranged attack is a gameplay ability that shoots flying projectiles or hitscan traces. Bows, guns, shotguns, grenades and spells use the same ability with different data.

Setup

  1. Make the shooter a combatant (see Combat).
  2. Create a Pulse Projectile data asset (UPulseProjectileDefinition, Primary Asset Type PulseProjectile) or fill InlineProjectile on the ability.
  3. Give UPulseRangedAttackAbility (or a Blueprint child) with the projectile definition as source object of the spec, or set Projectile on the ability.
  4. Press the ability input to shoot. With bCanCharge the shot leaves on release.

Projectile parameters (FPulseProjectileParams)

Group Fields
Flight Speed, GravityScale (0 straight, 1 arc), Lifetime, CollisionRadius, HitscanRange
Damage Damage, DamageType, DamageTags (Pulse.Combat.Damage.Ranged is always added), bCanCrit, DamageEffect, HitEffects
Piercing MaxTargets: combatants hit before the projectile stops (1 = no piercing). A blocking hit on an actor that takes damage (health set or IPulseDamageable, e.g. a wall of a building) is a direct hit, too.
Area AreaRadius (0 = none), AreaMultiplier at the center, AreaMinMultiplier at the edge. Area damage at the impact skips the targets hit directly and carries Pulse.Combat.Damage.Area.
Look Mesh, MeshScale (empty mesh = small sphere), ImpactCue (gameplay cue at the impact)

HitEffects are the same instanced structs as for melee and run on direct hits.

The ability

Property Meaning
bHitscan Trace instead of a projectile
ShotsPerAttack, SpreadDegrees Pellets and their spread cone. The spread is seeded per shot, so it is the same on every machine.
MuzzleSocket / MuzzleOffset Start of the shots
MaxAimDistance How far the camera aim trace looks for the aim point
bCanCharge, MaxChargeTime, FullChargeDamageMultiplier, FullChargeSpeedMultiplier Hold to charge
MaxOriginError, MaxAimDeviation Server check of client shots (0 = not checked)

Fire rate is a cooldown effect; ammunition is an attack cost (AttackCosts, Pulse costs, or the costs of the weapon that granted the ability, see Combat and inventory). On Fired is a Blueprint hook on the authority. APulseProjectile can be subclassed (set ProjectileClass in the definition) for own visuals or homing.

Aiming

  • Players: the shot goes towards the attack target (lock-on or soft target) or along the camera to the point the camera looks at. A client sends origin, direction and charge as target data; the server checks the origin against its muzzle (MaxOriginError) and the direction against the pawn’s aim rotation (MaxAimDeviation) and rejects implausible shots with a log warning. Both checks need a pawn whose movement and rotation reach the server (e.g. Character Movement); set them to 0 for pawns that move only locally.
  • AI and scripts: activate the ability on the server with the target in the event data, EventMagnitude = charge seconds:
FGameplayEventData data;
data.Target = Enemy;
Pulse::Combat::PressAbilityInput(AbilitySystem, UPulseRangedAttackAbility::StaticClass(), &data);

Multiplayer

Projectiles are spawned on the authority and replicate (parameters once, at spawn); clients only see them. Damage, piercing and area damage happen on the authority. Hitscan shots are traced on the authority.

Cheats

Command Does
PulseCombatGiveRanged [charge\|hitscan\|grenade\|asset path] Gives a ranged ability (default: straight projectile, 15 damage)
PulseCombatFire [release] Presses the ranged attack (release releases a charge)
PulseCombatSpawnTurret Spawns an enemy turret that shoots at the nearest player every two seconds (tests the server path)

PulseCore plugin documentation.

This site uses Just the Docs, a documentation theme for Jekyll.