Documentation
¶
Overview ¶
Package softtarget is the controller-aim tie-breaker for action games: given a set of swept-volume hit candidates, pick one as the canonical target using a caller-composed scoring function.
The kit doesn't gather candidates — that's the caller's spatial query. It only ranks them, with a `Pick` that's allocation-free after warmup. Use the same Resolver client-side (for the preview reticle) and server-side (for hit adjudication) to keep the two in lock-step.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate[T any] struct { Item T Position geometry.Vec3 AngularErr float32 // radians off the aim axis Distance float32 // distance from the player }
Candidate is one hit candidate the spatial query produced.
AngularErr and Distance are pre-computed against the player's aim axis so Pick doesn't recompute geometry per candidate.
type Config ¶
type Config[T any] struct { Score Score[T] // MaxAngularError rejects candidates outside this cone half-angle // (radians) before scoring. Set ≤ 0 to disable. MaxAngularError float32 // MaxDistance rejects candidates further than this. Set ≤ 0 to // disable. MaxDistance float32 }
Config configures a Resolver.
type Resolver ¶
type Resolver[T any] struct { // contains filtered or unexported fields }
Resolver picks one canonical target from a candidate list.
type Score ¶
Score returns a per-candidate scalar where higher wins. Compose caller-game-specific terms (HP, threat, debuff bias) on top of the built-ins via Compose.
func ScoreAngular ¶
ScoreAngular returns a Score that rewards small angular error. `weight` scales the contribution; `+1` at perfect aim, decaying to 0 as AngularErr → π.
func ScoreDistance ¶
ScoreDistance returns a Score that rewards close targets. `falloff` is the distance at which the contribution halves. `weight` scales the contribution.