group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
GamepadAimAssistSystem.hpp File Reference

AAA-style controller aim assist — applied after runGamepadLook. More...

#include "InputSampleSystem.hpp"
#include "ecs/components/CollisionShape.hpp"
#include "ecs/components/Controllable.hpp"
#include "ecs/components/InputSnapshot.hpp"
#include "ecs/components/LocalPlayer.hpp"
#include "ecs/components/PlayerVisState.hpp"
#include "ecs/components/Position.hpp"
#include "ecs/components/RespawnTimer.hpp"
#include "ecs/physics/Raycast.hpp"
#include "ecs/physics/WorldData.hpp"
#include "ecs/registry/Registry.hpp"
#include <SDL3/SDL.h>
#include <algorithm>
#include <cmath>
#include <glm/glm.hpp>
#include <glm/trigonometric.hpp>
#include <limits>
Include dependency graph for GamepadAimAssistSystem.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  systems::GamepadAimAssistConfig
 Tunable parameters for gamepad aim assist. More...
struct  systems::GamepadAimAssistState
 Per-frame state required to compute the rotational pull as a delta between frames. More...

Namespaces

namespace  systems
 Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent).
namespace  systems::aimassist

Functions

void systems::aimassist::dirToYawPitch (const glm::vec3 &dir, float &outYaw, float &outPitch)
 Convert a world-space direction into yaw/pitch matching the renderer convention used by cachedCamFwd_: fwd = (sin(yaw)·cos(pitch), −sin(pitch), cos(yaw)·cos(pitch)).
float systems::aimassist::coneFalloff (float angleRad, float innerRad, float outerRad)
 Linear cone falloff: 1.0 inside innerRad, 0.0 outside outerRad.
glm::vec3 systems::aimassist::rayOntoAABB (const glm::vec3 &eye, const glm::vec3 &dir, const glm::vec3 &aabbMin, const glm::vec3 &aabbMax, float fallbackDist)
 Find the world point where the camera ray hits the target's AABB, or — if it misses — the closest point on the AABB to the ray's projection at target distance.
void systems::runGamepadAimAssist (Registry &registry, SDL_Gamepad *gamepad, const GamepadAimAssistConfig &cfg, GamepadAimAssistState &state, float lookSens, float dt)
 Apply gamepad aim assist (slowdown + movement-tracking pull) to the local player's InputSnapshot.

Detailed Description

AAA-style controller aim assist — applied after runGamepadLook.

Two-stage controller assist that helps the player track, rather than locking onto a body part:

  1. AABB-anchored target slowdown / aim friction — when the crosshair is on an enemy, we refund part of the player's just-applied stick input, lowering effective sensitivity in the kill zone.
  2. Movement-tracking rotational assist — the camera receives a rotation toward where the anchor on the target moved between the last frame and this one, scaled by rotationalCompensation (default 0.6). The anchor is a point on the target's AABB that follows where the player is aiming — so dragging the stick up moves the anchor up on the body, dragging right moves it right, etc. The player picks where on the body to track; aim assist just contributes a fraction of the angular velocity needed to stay glued to that point as the enemy and player move around.

Why this is weaker than head/torso magnet pull:

  • A stationary enemy contributes ZERO rotational pull (no aimbot when standing still — Δanchor_world = 0).
  • The pull is gated by change in apparent position, scaled by a fraction (so the player still has to aim).
  • There's no head preference — the player's view chooses where on the body to track. Want to land headshots? Aim a bit higher and the anchor follows.

Activation gate — both effects are gated on the player actually moving a stick (≥5% on either left or right stick by default). Holding still gives full manual control. Standard CoD/Apex/Halo convention.

Server-blind — modifies only the local player's InputSnapshot.yaw/ pitch, so prediction & replication are unaffected.

Mouse-only players see nothing — the system early-outs when no gamepad is connected.