Spectator Camera (freecamera)

[Re-Usable] Spectator Camera (freecamera) 2.3

Spectator Camera — Changelog V2.3​

Advanced Cinematic Cuts​

The static (fixed) camera mode has received a major upgrade to make viewing much more cinematic. Instead of cutting instantly the moment a target goes out of frame, the camera now uses intelligent timers.

New Console Variables (CVARs)​

To support the new cinematic cut system, three new customizable variables have been introduced:
  • sc_distance_reset: Defines the maximum distance (in FRACUNITs) the tracked object can travel away from the camera before a reset is triggered. (Default: 2048)
  • sc_time_distance_reset: The delay (in seconds) the camera will wait before cutting to a new position after the target exceeds the maximum distance limit. (Default: 3 seconds)
  • sc_time_sight_reset: The delay (in seconds) the camera will wait before cutting to a new position after losing direct line-of-sight with the target. (Default: 0 seconds)

LithiumCore Integration​

Full native compatibility with the LithiumCore mod has been added!
  • Unified Menus: If LithiumCore is detected on the server, the Spectator Camera settings will automatically inject themselves into LithiumCore's subcategory menu system.
  • Safe Overrides: The addon intelligently suppresses its own standalone HUD hooks and menu inputs when LithiumCore's interface or scoreboards are active, preventing menu overlaps or UI soft-locks.
This update focuses on visual polish for the GUI, smoother camera transitions, and smarter tracking logic.

Spectator Camera — Changelog V2.2​

UI & Menu Polish​

  • Animated Menu Background: The in-game Settings and Keybinds menu has received a massive visual upgrade. It now features a stylish, animated scrolling background with a smooth alpha-blended fade-in and fade-out transition.
  • Close Button: Added a clickable "X" close button to the top-right corner of the settings menu for easier mouse navigation.
  • HUD Safety Override: If you open the settings menu while the game's native HUD is hidden, the addon will now automatically force the HUD back on so you don't get soft-locked in an invisible menu.

Camera & Tracking Improvements​

  • Smooth Center View: In Free Camera mode, pressing the "Center View" key no longer instantly snaps your vision. The camera's Pitch and Roll will now smoothly interpolate back to the horizon, making resets look much more natural and cinematic.
  • Smart Enemy POV Tracking: When using the Fixed (1st-Person) view in Object Mode to spectate Enemies or Bosses, the camera will now dynamically tilt up and down to look at whatever the enemy is currently targeting!

New Settings & CVARs​

Two new settings have been added to the in-game GUI menu and console:

  • Camera HUD sc_camerahud: The camera telemetry HUD toggle is now tied to a saved CVAR. When you toggle the HUD via your keybind or the settings menu, the game will permanently remember your preference across sessions.
  • Map Change Persistence sc_remove_on_mapchange: A new setting that dictates what happens when the server changes levels. By default (Yes), the camera is removed when a map changes. You can set this to "No" if you want the spectator camera to persist seamlessly between map loads.
This update brings some highly requested quality-of-life improvements to the UI, completely fixes the movement stuttering on online servers, and squashes a critical bug for actual in-game spectators.

Spectator Camera — Changelog V2.1​

Full Mouse Support for Settings UI​

  • Mouse Navigation: The in-game Settings and Keybinds menu can now be fully navigated using the mouse.
  • Click to Bind: Simply Left-Click on any input field to start binding a new key/button.
  • Quick Unbind: Right-Click on any bound key to quickly clear/remove it.
  • Smooth Scrolling: Added the ability to scroll through the menu using the Mouse Wheel, as well as clicking and dragging the scrollbar directly.
  • Visual Polish: Added a custom mouse cursor.

Ping-Friendly Object Tracking Movement​

  • No More Spinning/Jerking: Previously, the script translated forward/side inputs in a way that conflicted with the game engine on servers with high latency (ping), causing the player character to violently spin in place. The new system calculates an absolute world-angle vector, ensuring your character runs perfectly smooth and in the correct camera-relative direction, regardless of your ping to the server.

Bug Fixes & Code Improvements​

  • Native Spectator Crash Fixed: Fixed a critical bug where players who were in the game's actual "Spectator" state (dead or joined as spectator) would encounter console errors and be completely unable to move the free camera due to missing mobj.
  • Combo Key Sorting: Multi-key bindings (e.g., holding modifiers) are now smartly sorted. Modifier keys like Ctrl, Alt, and Shift will properly prioritize themselves in the display name string for cleaner readability.
  • Input Hook Optimization: Moved the settings menu input processing from the rendering block HUD to PreThinkFrame, ensuring clicks and button presses are registered more accurately and safely.
  • CVAR Tweaks: Renamed the ps option in the sc_gamepad CVAR to playstation to be more descriptive.
This is a massive milestone update. The entire architecture of the addon has been rebuilt from the ground up to operate completely on the client-side, bringing zero-latency controls, an in-game GUI, and a highly requested custom binding system.

Spectator Camera — Changelog V2.0​

Complete Client-Side Overhaul​

  • Local Execution: The camera logic now runs entirely on the client side. Camera data is no longer stored on the server.
  • Zero Input Lag: Because the camera is no longer tied to server tics for movement calculations, viewing and flying around is perfectly smooth and independent of network ping.
  • Local Configurations: All your settings and keybinds are now saved locally to your device (client/sc_controls.cfg and client/sc_config.cfg).

Custom Controls & In-Game GUI​

  • New Settings Menu: Added a fully functional, scrollable in-game GUI menu to manage settings and bindings (accessible via "I" by default or the sc_settings command).
  • Advanced Binding System:You can now rebind every single action.
    • Supports multi-key combinations (e.g., lctrl+y).
    • Supports multiple bindings per action (e.g., you can bind "Move Forward" to both W and D-Pad Up).
  • Dynamic HUD Prompts: The HUD now reads your custom bindings and displays the correct keys/buttons dynamically based on what you have set.

Enhanced Gamepad Support​

  • Smart Controller Detection: The script automatically detects if you are using a mouse/keyboard or a gamepad and updates the HUD prompts accordingly.
  • Layout Profiles: Added the sc_gamepad CVAR. You can now choose your controller layout (Xbox, PlayStation, or Nintendo), and the in-game menu and HUD will display the correct button icons (e.g., Cross/Circle, A/B, Triangle/Y).

New Tracking & Camera Mechanics​

  • Gaze-Based Target Selection: In Free Camera mode, you can now look directly at any player, enemy, or boss, press the "Track Object" button, and the camera will instantly snap to track them
  • Camera-Relative Player Movement: When tracking yourself in Third-Person mode, your movement controls (W/A/S/D) are now completely relative to where the camera is looking, rather than where the character is facing.
  • Smooth Orbit System: The Object Tracking mode now features an orbit system. Rotating around your character and zooming in/out is now heavily interpolated, resulting in buttery-smooth camera panning.
  • Player Cycling: Added dedicated binds ("Previous Player" / "Next Player") to quickly cycle through active players in the server without using console commands.

Technical Additions & Tweaks​

  • New CVARs: Added sc_cinema_damp and sc_glide_damp to allow players to manually tune the exact friction and smoothing weight of the cinematic and glide modes via the menu.
  • Input Safeties: Added strict key blacklists (e.g., Esc, Windows Key, F8) to prevent players from accidentally binding over critical system or SRB2 hardcoded keys.
  • Math Optimization: Core mathematical functions (FixedMul, sin, cos) are now localized at the top of the script for faster execution during the ThinkFrame loop.
This update focuses on making the camera with the addition of a smart fixed-angle system, smooth zooming, and safety controls to prevent accidental inputs.

Spectator Camera — Changelog V1.3​

New Feature: Smart Fixed Camera​

The logic for the Non-Following Object Mode (when "Follow" is disabled) has been completely rewritten.

  • Position History System: The addon now records the movement history of the tracked object.
  • Auto-Repositioning: If the tracked object goes too far away or breaks Line of Sight, the camera will intelligently search its history to find a new, valid vantage point and cut to it automatically.
  • Dynamic Height: The camera anticipates vertical movement when calculating new angles to keep the subject in frame.

Visual & Control Improvements​

  • Smooth FOV Interpolation:
    • Changing FOV is no longer instant/snappy. It now interpolates smoothly, giving a high-quality easing effect when zooming in or out.
    • Adjusted Limits: The negative FOV limit has been restricted. Because an FOV of less than 52 has no effect..
  • Control Locking:
    • New Key Combo: Press Toss Flag + Fire in Object Mode.
    • Function: This locks all camera control buttons (C1, C2, C3, and Rotation).
    • Use Case: Perfect for recording gameplay or "Let's Plays" where you want to play as the character without accidentally moving the camera, toggling HUDs, or switching modes during intense action.
    • HUD Update: The HUD now displays the status of "Block Buttons".

Bug Fixes & Code Cleanup​

  • Collision Logic: Updated MobjMoveBlocked mechanism to return true, providing smoother interaction when the camera touches walls (preventing the camera from getting stuck in Block Enemies linedefs).
  • Code Formatting: General cleanup of spaces and operator formatting for better readability.

Updated Controls Reference (Object Mode):​

  • Toss Flag + Fire (Attack): Toggle Control Lock (Prevents accidental camera changes).
  • Weapon Next/Prev: Smooth Zoom In/Out.
  • Cool
Reactions: Kegla
The main focus of this update is a complete overhaul of the input system for single player. The camera now works in Record Attack Replays.

Spectator Camera - Changelog V1.2​

New Input System (Direct Input)​

In previous versions, the camera relied on player.cmd, which introduced slight input lag even in singleplayer because inputs were processed as "network" .
  • Singleplayer:
    • Implemented direct key reading via input.gameControlDown.
    • Gamepad Support: Added full support for analog sticks.
  • Multiplayer:
    • Logic automatically reverts to player.cmd to maintain synchronization between clients.

Camera Physics Improvements​

  • Roll Acceleration:
    • In Free Camera mode, when manually tilting the camera (FireNormal + Strafe), the tilt no longer snaps to a fixed speed. It now has smooth acceleration, allowing for precise micro-adjustments to the horizon line.
  • Command Optimization:
    • Toggling the menu/mod (F6) in Singleplayer is now instantaneous. It calls the function directly, bypassing the console buffer (COM_BufInsertText) to eliminate activation delay.

Record Attack Replays Compatibility​

  • Added a global check for modeattacking.
  • Now, when watching replays or playing Time Attack, the mod does not block player's angles or reset their inputs. This prevents "Ghost" desynchronization and ensures replays play back correctly without the camera mod interfering.
  • The "Block Player Movement" indicator is hidden from the HUD in this mode.

Technical Fixes & Code Refactoring​

  • Command Refactoring: The core console command logic has been moved to a separate function, cmd_main, allowing it to be called directly from Lua scripts.
  • Safety Checks:
    • Added gamestate ~= GS_LEVEL checks to ensure the camera doesn't attempt to run in menus or the score tally screen.
    • Improved object validation (specifically in getSelfPlayer) to prevent console errors if the player object isn't fully initialized (valid check).
This update is a major overhaul: the movement code has been rewritten, new flight modes have been added, the physics have been improved, and the interface has been completely redesigned.

Spectator Camera - Changelog V1.1​

New Features​

  • 6DOF Mode (Six Degrees of Freedom):
    • Added the ability to rotate the camera freely on all axes without limitations (eliminated "gimbal lock"). You can now fly upside down or at any angle.
    • Implemented a new axis system calculation to ensure controls remain intuitive regardless of the camera's orientation.
  • Glide Mode:
    • Added movement inertia. The camera no longer stops instantly but slows down smoothly, allowing for fluid, cinematic shots.
  • Function Toggles (Weapon Mask):
    • Control over modes has been moved to the Weapon/Ring select buttons (Weapon Mask 1-5).
    • You can now quickly toggle: Cinematic, Glide, 6DOF, Noclip, and Gravity.

Free Camera Improvements​

  • Rewritten Movement Physics:
    • Movement is now calculated via vectors relative to the camera's actual orientation.
    • Strafing (moving sideways) now works correctly even if the camera is upside down.
  • Cinema Smoothing:
    • Improved the mouse smoothing algorithm for smoother camera pans in Cinematic Mode.
  • Gravity Logic:
    • Gravity mechanics have been refined: the camera now interacts correctly with momentum when in Glide mode.

Interface (HUD)​

  • Complete HUD Redesign:
    • Information is now split into two neat panels (Left and Right).
    • Uses a compact font (small/small-right) for a cleaner look.
  • Right Panel (Telemetry):
    • Displays precise data: Yaw, Pitch, Roll, Coordinates (X, Y, Z), current FOV, and Speed.
  • Left Panel (Status & Controls):
    • Shows the state of all toggles (ON/OFF) for: Cinema, Glide, 6DOF, Noclip, Gravity.
    • Displays context-aware control hints depending on the current mode (Freecamera or Object).

Technical Changes & Optimization​

  • Code Structure:
    • The logic has been split into separate blocks: UpdateFreeCamera and UpdateObjectCamera, making the code easier to maintain.
    • Implemented local variables for math functions (FixedMul, sin, cos) to improve Lua performance.
  • Console Commands:
    • Argument parsing for the spectator_mode freecamera command (flags like -x, -y, -z) is now more robust (using pattern matching).
  • Bug Fixes:
    • Improved handling of MF_NOCLIP and MF_NOGRAVITY flags — they no longer conflict with server settings.
    • Fixed camera behavior when tracking objects with reversed gravity (Object Flip).

Updated Controls Reference:​

In Free Camera mode:
  • 1 (Weapon 1): Toggle Cinematic Mode.
  • 2 (Weapon 2): Toggle Glide (Inertia).
  • 3 (Weapon 3): Toggle 6DOF (Free Rotation).
  • 4 (Weapon 4): Toggle Noclip.
  • 5 (Weapon 5): Toggle Gravity.
  • C1 + Next/Prev Weapon: Adjust Speed.
  • C2: Center view.
  • C3: Quick switch to self-tracking.
  • Cool
Reactions: luigibudd
Top