Files
CosmicClash/FLIGHT_MANUAL.md
Josh Creek 076d27a564 feat(input): full controller support, rebindable controls, and rotation fixes
Playing with a gamepad did not work: all six move_* actions had no joypad
event at all, so a pad could yaw/pitch/roll/turbo but could not translate.
Nothing caught it because every action existed and the game booted fine —
no assertion checked that an action is reachable on *both* devices.

Controller layout, on the 6DOF convention (left stick aims, right stick
translates), using all six of the pad's analog axes for the ship's six
degrees of freedom:

  left stick   yaw + pitch        right stick  strafe + vertical
  LB / RB      roll               RT / LT      forward / back
  L3           turbo              R3           ball camera

Input is now read with Input.get_axis instead of is_action_pressed, so
triggers and sticks are proportional. Keyboard values are unchanged.

Three rotation bugs found by measuring a real Ship rather than reading the
code:

- apply_torque() is world-space and the torque was never rotated into the
  hull's frame (unlike thrust, which uses -ship_basis.z). Roll input became
  pitch after a 90 degree turn and inverted at 180, so the controls were
  correct flying up-field and backwards flying back.
- ship.tscn's inertia is Vector3(7, 1, 7) but a flat torque was applied to
  every axis, giving yaw 7x the angular acceleration of pitch and roll
  (172 deg/s vs 52). Torque is now scaled per-axis by inertia, so
  rotation_acceleration means rad/s^2 and all three axes match. Yaw is
  unchanged.
- pitch_down pitched the nose UP: get_axis's arguments were reversed, so
  the I/K keys and the stick each did the opposite of their label.

Menus were unusable on a pad for a separate reason: Godot 4.7 gives
ui_up/down/left/right joypad events by default but leaves ui_accept and
ui_cancel with none (verified against a pristine project), so a controller
could move the highlight and never press anything. A confirms and B goes
back. Gameplay exits on a new leave_gameplay action (Escape / Start) rather
than ui_cancel, so carrying B for menus cannot abandon a live match.

Bindings for both devices are rebindable in Settings -> Controls, persisted
to user://input.cfg — a separate file from settings.cfg because
VideoSettings.save() rewrites that file wholesale and would drop any
section it does not know about. project.godot stays the source of truth for
defaults; overrides are only ever a delta on top of a boot-time snapshot.

Verified: 268 unit tests, the ENet integration gate, and a 16-sample
before/after comparison of networked prediction residuals showing the
physics change does not regress them (median 0.083m -> 0.065m).

Note for follow-up: every policy in Game/bots/ was trained against the old
sluggish, world-axis rotation and will over-rotate until retrained.
2026-09-06 20:41:20 +01:00

227 lines
7.6 KiB
Markdown

# 🚀 Cosmic Clash Flight Manual
Welcome to space, pilot! This guide will teach you everything you need to know about piloting your ship in the vast cosmos.
## 🎮 Control Schemes
### Keyboard Controls
#### Translation (Movement)
- `W` - Forward Thrust (Main Engines)
- `S` - Reverse Thrust (Retro Engines)
- `A` - Strafe Left (Port Thrusters)
- `D` - Strafe Right (Starboard Thrusters)
- `E` - Thrust Up (Dorsal Thrusters)
- `Q` - Thrust Down (Ventral Thrusters)
- `Shift` - Turbo Boost (Forward Only)
#### Rotation (Attitude Control)
- `J` - Turn Left (Yaw Left)
- `L` - Turn Right (Yaw Right)
- `I` - Pitch Up (Nose Up)
- `K` - Pitch Down (Nose Down)
- `U` - Roll Left (Bank Left)
- `O` - Roll Right (Bank Right)
### Controller Controls
Button names are the Xbox layout; a PlayStation pad maps the same physical
positions (A = ✕, B = ○, X = □, Y = △).
**The left stick points the nose, the right stick moves the hull.** Your ship has
six degrees of freedom and a pad has exactly six analog axes, so every one gets a
real axis rather than an on/off button.
#### Rotation — left stick and shoulders
- Left Stick (left/right) - Yaw
- Left Stick (up/down) - Pitch. Flight-sim polarity by default: **push the
stick forward and the nose goes down.** Flip it with "Invert pitch" in
Settings → Controls.
- `LB` - Roll Left (Bank Left)
- `RB` - Roll Right (Bank Right)
#### Translation — right stick and triggers
- `RT` - Forward Thrust (Main Engines)
- `LT` - Reverse Thrust (Retro Engines)
- Right Stick (left/right) - Strafe (Port/Starboard Thrusters)
- Right Stick (up/down) - Thrust Up/Down (Dorsal/Ventral Thrusters)
- `L3` (click the left stick) - Turbo Boost
`X` and `Y` are deliberately unused in flight, and `A`/`B` are menu-only, so a
reflexive face-button press never does anything mid-match.
#### Menus
- D-Pad or Left Stick - move the highlight
- `A` - select
- `B` - back
- `Start` - leave a match in progress (deliberately not `B`, which is too easy
to press by accident mid-game)
#### Other
- `R3` (click the right stick) - Toggle ball camera
- `D-Pad Up` - Reset the ball (Free Play only)
The triggers and sticks are **analog**: a half-pulled trigger gives half thrust,
and a gentle stick lean gives a gentle turn. Keyboard keys are all-or-nothing,
which is the main reason a pad is easier to fly precisely.
### Rebinding
Every control above — keyboard and controller alike — can be remapped in
**Settings → Controls**. Pick the device with the Keyboard/Controller toggle,
click the binding you want to change, and press the key or button to assign.
Binding an input that is already in use unbinds it from the action that had it,
and the screen tells you which. "Reset all bindings to defaults" restores this
table.
## 🛸 Basic Flight Principles
### Understanding Your Ship
Your ship is a **realistic space vehicle** with the following characteristics:
- **Momentum Conservation**: You keep moving even when not thrusting
- **Independent Rotation**: Your ship can face any direction while moving in another
- **Thruster-Based Movement**: Different thrusters provide different amounts of force
### Thruster Systems
1. **Main Engines** (Forward/Reverse): Most powerful, used for primary acceleration
2. **Maneuvering Thrusters** (Strafe/Vertical): Less powerful, for precise positioning
3. **Attitude Control** (Rotation): Independent rotational control around all three axes
## 🎯 Flight Techniques
### Beginner Maneuvers
#### Basic Movement
1. **Forward Flight**: Hold `W` to accelerate forward
2. **Turning**: Use `J`/`L` to turn left/right while moving
3. **Stopping**: Turn around 180° and thrust forward to decelerate
4. **Hovering**: Use vertical thrusters (`E`/`Q`) to maintain altitude
#### Camera Control
- **Ball Cam**: Press `Space` (or `R3` on a controller) to toggle ball tracking camera
- **Ship Cam**: Normal follow camera that looks where your ship points
### Intermediate Maneuvers
#### Efficient Movement
1. **Momentum Management**: Coast when possible to conserve energy
2. **Precision Landing**: Use gentle bursts of opposing thrust
3. **Quick Turns**: Combine rotation with strafe thrusters for sharp direction changes
#### Combat Positioning
1. **Strafing**: Move sideways while keeping guns on target
2. **Evasive Maneuvers**: Unpredictable movement patterns using all thrusters
### Advanced Techniques
#### Orbital Mechanics
1. **Prograde Burn**: Thrust in direction of movement to speed up
2. **Retrograde Burn**: Thrust opposite to movement to slow down
3. **Radial Burns**: Thrust perpendicular to movement to change orbit
#### Expert Maneuvers
1. **Flip and Burn**:
- Accelerate forward until at desired speed
- Rotate 180° while maintaining momentum
- Fire main engines to decelerate efficiently
- Most fuel-efficient way to stop
2. **Translation Sliding**:
- Build up forward momentum
- Use strafe thrusters to "slide" sideways
- Maintain forward velocity while moving laterally
3. **Zero-G Ballet**:
- Combine all rotation axes for complex orientation changes
- Use momentum to coast through tight spaces
- Master the "six degrees of freedom"
## 🎮 Ball Cam vs Ship Cam
### Ball Cam Mode (`Space` / `R3` to toggle)
- **Camera**: Always looks toward the ball
- **Ship Control**: Based on ship orientation (NOT camera view)
- **Best For**: Tracking the ball during gameplay
- **Challenge**: Movement direction may not match what you're looking at
### Ship Cam Mode
- **Camera**: Looks where your ship is pointing
- **Ship Control**: Intuitive - forward is where you're looking
- **Best For**: Precise navigation and docking
- **Advantage**: What you see is where you'll go
## ⚡ Energy Management
### Turbo System
- **Activation**: Hold `Shift` (keyboard) or `L3` (controller) while thrusting forward
- **Effect**: 2.5x thrust multiplier on main engines only
- **Strategy**: Use for quick acceleration or emergency maneuvers
### Thrust Efficiency
- **Main Engines**: Most powerful, use for primary movement
- **Maneuvering Thrusters**: Less powerful but more precise
- **Conservation**: Coast on momentum when possible
## 🏆 Mastery Tips
### "Easy to Learn, Hard to Master"
1. **Start Simple**: Learn basic forward movement and turning
2. **Add Complexity**: Gradually incorporate strafe and vertical movement
3. **Master Physics**: Understand momentum and how forces combine
4. **Think in 3D**: Space has no "up" - use all six degrees of freedom
### Skill Development Path
1. **Novice**: Can fly forward and turn
2. **Pilot**: Comfortable with all basic movements
3. **Ace**: Uses momentum and efficient maneuvering
4. **Commander**: Masters complex orbital mechanics and combat flying
### Practice Exercises
1. **Figure-8 Flying**: Practice smooth turns and momentum control
2. **Precision Landing**: Land gently on targets using minimal thrust
3. **Obstacle Course**: Navigate tight spaces using translation controls
4. **Combat Training**: Practice keeping guns on target while evading
## 🔧 Tuning Your Ship
The following parameters can be adjusted for different flight characteristics:
- **Thrust Power**: How quickly you accelerate
- **Maneuvering Thrust**: Precision vs power for side movement
- **Rotation Power**: How quickly you can turn
- **Drag Coefficients**: How much momentum you retain
## 🌌 Welcome to Space
Remember: In space, every action has an equal and opposite reaction. Master the physics, and you'll master the game. Your ship responds to real forces - there's no magic "turn toward movement" or artificial limitations.
**Fly safe, pilot. The cosmos awaits!**
---
_"The universe is not only stranger than we imagine, it is stranger than we can imagine." - But your ship controls make perfect sense once you learn them._