Hitscan class final

Fires a weapon's rays into the world and reports where they landed.

The spread is mostly not random

A shotgun's pellets follow a fixed pattern — one down the middle and the rest on a ring — with only a small random jitter on top. Fully random spread makes the same shot at the same range do wildly different damage, which reads to a player as the game cheating rather than as variance. A fixed pattern means a shotgun at close range always kills what it is pointed at, and that reliability is the whole character of the weapon.

The jitter exists so two consecutive shots do not draw identical tracers.

What it tests against

The collision world, not the render meshes. Those are two different things — a wall is one merged surface per material by the time it is drawn — and the player's expectation is set by what they cannot walk through.

Constructors

Hitscan({required CollisionWorld world, required GameRandom random})

Properties

hashCode → int
The hash code for this object.
no setterinherited
random → GameRandom
The generator the jitter comes out of.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
world → CollisionWorld
final

Methods

fire(WeaponDef weapon, Vector3 origin, Vector3 aim, {Collider? ignore, int mask = CollisionLayers.all}) → List<ShotHit>
Fires one shot and returns a hit per ray, in pattern order.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

damageByTarget(List<ShotHit> hits, {double scale(ShotHit hit)?}) → Map<Collider, double>
Total damage a shot delivered to one collider.

Constants

jitterFraction → const double
How far the jitter can move a ray, as a fraction of the weapon's spread.