OpenBodyCams
An open-source implementation of a body/head camera that is displayed on the bottom right monitor in the ship, with the goal of appearing almost identical to the player's actual perspective while providing good performance.
Date uploaded | 2 months ago |
Version | 2.3.1 |
Download link | Zaggy1024-OpenBodyCams-2.3.1.zip |
Downloads | 91381 |
Dependency string | Zaggy1024-OpenBodyCams-2.3.1 |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100README
OpenBodyCams
An open-source implementation of a body/head camera that is displayed on the bottom right monitor in the ship, with the goal of appearing almost identical to the player's actual perspective while providing good performance.
When LethalLib is installed, the body cam will not be available until an antenna is bought as a ship upgrade in the store.
The camera view will display only the first person hands and hide the third person model as well as many mods' third-person cosmetics to prevent obstructed vision. Vanilla enemies that cling to the player are also supported.
Please report any issues here, and include any relevant information according to the Debugging section.
Features
- Selectable camera perspective between the head and body.
- Camera view is designed to render identically for the local player and other players in the game.
- MoreCompany and AdvancedCompany cosmetics support, see the Compatibility section.
- All enemies, terrain, etc. that is visible to the player will be visible in the camera view.
- The same green flash animation used when switching targets on the radar is displayed by the camera view.
- Performance:
- The camera is attached to the player model in the engine rather than copying the transform from it.
- Camera setup logic is done ahead of time based on game events whenever possible.
- A opt-in
view bodycam
command in the terminal displays the body cam when viewing the radar map. See Configuration/Terminal
Compatibility
MoreCompany cosmetics, AdvancedCompany cosmetics and equipment, and third-person model replacements by ModelReplacementAPI and LethalVRM are supported. They will be hidden when viewing other players in the body cam, and your cosmetics/models will be visible on the camera when you are viewing another player looking at you.
GeneralImprovements's extended monitors set is supported through a config option to select the monitor number to use for the body cam. The body cam will override any selection in the GeneralImprovements config.
TwoRadarMaps will use a separate body cam for the picture-in-picture view in the terminal when EnablePiPBodyCam
is enabled.
Screenshots
Configuration
Camera options
Mode
: The attachment point of the camera. The head and the body are selectable.HorizontalResolution
: The horizontal resolution of the rendered view.FieldOfView
: The vertical FOV of the body cam's view.RenderDistance
: The far clip plane of the camera.Framerate
: The number of frames to render per second. The default setting renders the body cam at the game's framerate. Setting this to a value below approximately 75% of the game's average framerate with the body cam disabled will improve performance significantly.NightVisionBrightness
: A multiplier for the brightness and range of the night vision light. A value of 1 matches the vision of the player being viewed.MonitorEmissiveColor
: The color to emit from the screen displaying the body cam. Represented as comma-separated numbers to avoid losing precision by using a 32-bit color.MonitorTextureFiltering
: Changes the texture filtering applied to the screen for the body cam. Point will result in sharp edges on the pixels, while bilinear and trilinear should both smooth out colors between them.RadarBoosterPanRPM
: This controls the number of turns that the camera should make each minute. If set to 0, the camera will be fixed in the direction that the player placing the radar booster was facing.UseTargetTransitionAnimation
: If enabled, the body cam will display a green flash animation when changing targets to mirror the behavior of the radar map.DisableCameraWhileTargetIsOnShip
: This will cause the screen to turn off while the camera's target is onboard the ship. This can be used to avoid the load of rendering large numbers of items on the ship in long runs.EnableCamera
: When this is enabled, the screen will be powered off. This can be changed in-game with LethalConfig or any similar mod.DisplayOriginalScreenWhenDisabled
: When enabled, whatever was on the screen that the main body cam replaced will be displayed when the body cam has no valid target, or when disabled by theDisableCameraWhileTargetIsOnShip
option. This currently has no effect when GeneralImprovements's UseBetterMonitors option is enabled.
Terminal
EnablePiPBodyCam
: Off by default, this adds aview bodycam
command to the terminal that displays the body cam in one corner of the radar map. When the radar map is hidden, the body cam will be hidden as well.PiPPosition
: Selects the corner of the radar map that the body cam view in the terminal should reside in.PiPWidth
: Sets the horizontal size of the body cam view in the terminal. This does not affect the render resolution of the camera.
Ship Upgrade
Enabled
: On by default, but only active when LethalLib is found, this causes the main body cam to only be available when an antenna prop is bought in the store. Note that this prop is only available with LethalLib.Price
: The price of the body cam upgrade in the store, with the default cost being 200 credits.
Ship
SwapInternalAndExternalShipCameras
: Swaps the external and internal cameras which are displayed on the right side of the screen array. This has no effect when GeneralImprovements's UseBetterMonitors option is enabled.DisableCameraOnSmallMonitor
: Disables the camera that is displayed on the small monitor, which will be the internal camera ifSwapInternalAndExternalShipCameras
is not enabled. This may improve performance inside the ship slightly. This has no effect when GeneralImprovements's UseBetterMonitors option is enabled.ExternalCameraEmissiveColor
: Sets the color emitted from the screen that displays the external camera.
Miscellaneous
FixDroppedItemRotation
: Defaulted totrue
, this fixes a desync of items' rotations when dropping them. See Notes/Item rotations.
Debug
See Debugging.
Notes
Item rotations
An optional fix is included for items' rotations being desynced between the player dropping them and all other clients, which is caused by an ignored rotation parameter in the function handling dropped items. This is included to allow the radar boosters to face in a consistent direction for all clients in a game. The patch is designed to fail gracefully and allow the mod to still run, in case any other mods apply the same fix, but if problems arise, it can be disabled with the FixDroppedItemRotation
config option.
Debugging
When providing logs for issues you encounter, PLEASE make sure to enable Unity logging!
- Set BepInEx's
UnityLogListening
option in the[Logging]
section totrue
. - Set BepInEx's
LogLevels
option in the[Logging.Disk]
section toAll
. - Disable DisableUnityLogs if installed.
Otherwise, there will be no error messages printed in the logs at all, and I cannot narrow down the cause of the problem.
The logs can be found in the BepInEx folder within the mod manager's profile folder (%appdata%\r2modmanPlus-local\LethalCompany\profiles\[profile name]
for r2modman), or inside the game's Steam install folder. Please ensure that the modification date indicates that the file is the most recent launch of the game.
Screen freezes/error spam
If error spam or screen freezes are encountered, please reproduce the issue with ReferencedObjectDestructionDetectionEnabled
enabled in the [Debug]
section of the config, then provide the game logs in a new issue on GitHub (see Debugging to find the .log
file). The option prints a message and stack trace whenever an object is destroyed while a body cam is referencing it. This should point directly to any problematic mods causing issues.
After the issue occurs, BruteForcePreventFreezes
can be used to resume normal gameplay. The option prevents the error spam by checking every frame whether any cosmetics on viewed players have been destroyed and updating the list if so. This can be used as a stopgap measure to prevent screen freezes if a mod conflict is unavoidable.
"Collected cosmetics" spam
If messages are spammed excessively in the console/logs saying Collected [x] cosmetics objects for [name]
, then the PrintCosmeticsDebugInfo
can be enabled to provide information on what is causing the collection of the cosmetics. Enable this option while the issue is occurring and provide the logs in a GitHub issue (see Debugging to find the .log
file). It will print extra information about the cosmetics being collected for each player, as well as the code that is causing the cosmetics to be collected.
Developers
If you wish to create a body cam separate from the default one included with this mod, you can simply add OpenBodyCams as a dependency and use OpenBodyCams.API.BodyCam.CreateBodyCam()
:
var doorScreen = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/SingleScreen");
BodyCam.CreateBodyCam(doorScreen, doorScreen.GetComponent<MeshRenderer>(), 1, StartOfRound.Instance.mapScreen);
The body cam component will be attached to the provided GameObject
, and use the provided Renderer
to check whether the display it is on is being rendered.
The displayMaterialIndex
argument indicates which of the shared materials on the renderer should be replaced by the body cam's render texture. The texture that is in that index originally will be stored by the body cam, and when SetScreenPowered(false)
is called, it will replace the body cam's output on the display. The body cam's output can then be brought back with a SetScreenPowered(true)
call.
The ManualCameraRenderer
argument must be a map renderer where its cam
field is the same reference as its mapCamera
field. However, the argument may be null, in which case the body cam's target may be controlled directly.
Credits
- smxrez - Body cam antenna 3D model
CHANGELOG
Version 2.6.0
- Updated the MoreCompany compatibility patch to spawn cosmetics on the local player. The compatibility feature now requires MoreCompany version 1.11.0 and above.
Version 2.5.2
- Fixed an issue that would cause the outdoor ambient lighting to flicker when the body cam frame rate was limited.
Version 2.5.1
- Repackaged 2.5.0 to remove some leftover code causing issues on rainy moons.
Version 2.5.0
- Added a ReservedItemSlotCore compatibility feature to hide/show holstered items based on perspective.
- Sky effects are changed based on the camera perspective. When a body cam target is looking down a long hallway in the interior, the end of the hallway will now be dark.
- Made body cams be unaffected by the game's gamma setting and the tonemapping pass. This should help with visibility in dark areas, as well as prevent the screen from getting excessively bright when gamma is above normal.
- Added a patch to fix a vanilla bug that prevents players converted by a masked enemy from being targeted by the map.
- Fixed the overlay text for buying the antenna being visible upon joining a game with the body cam unlocked and placed.
- Fixed an issue that caused the PiP command to be unusable after restarting a game.
- Made the MoreCompany compatibility mode continue to function if the patch to spawn cosmetics for the local player fails.
- Prevented compatibility features from stopping mod initialization.
Version 2.4.5
- Fixed an error that would occur when loading a save with the PiP body cam disabled.
Version 2.4.4
- Fixed the body cam staying visible in the terminal when going to orbit.
Version 2.4.3
- Made the initialization at the start of the game much less likely to be prevented by errors from other mods.
Version 2.4.2
- Fixed an error that would occur when GeneralImprovements's
UseBetterMonitors
option is enabled.
Version 2.4.1
- Hid the overlay when the body cam's screen is powered off.
- Added an option to set the text displayed when the body cam is rendering normally. This is currently independent of whether a player is living or dead.
- Switched initialization to use a different hook to (hopefully) avoid broken saves causing the body cam not to function.
Version 2.4.0
- Added an overlay that indicates the reason the body cam is not visible. The supported states are:
- The ship upgrade is enabled, but the body cam antenna has not been bought yet.
- The antenna is bought but stored, preventing body cams from being used.
- The body cam's target is invalid, e.g. when the targeted player has been eaten and has no corpse.
- The body cam is disabled due to its target being safe on the ship.
- Fixed the body cam not appearing when the GeneralImprovements option for extra monitors was enabled while the mesh it depends on is disabled.
- Disabled the body cam view when it is attached to a radar booster in a belt bag to avoid seeing the items stacked in the void.
- API changes:
- Added the static
BodyCam.MainBodyCam
property to get the body cam displayed on the ship monitors. - Improved organization of the
BodyCamComponent
members, moving API to the top and adding comments.
- Added the static
Version 2.3.1
- Fixed some issues that could cause breakage or crashes upon loading a corrupted save.
- Fixed an issue preventing the body cam from functioning if another mod removes the camera from the small monitor with
DisableCameraOnSmallMonitor
enabled.
Version 2.3.0
- Reduced overhead when applying framerate limit to the body cam. There is no longer a downside to setting a framerate limit instead of letting the camera render every frame, and performance will scale as expected.
- Fixed light flickering that could occur on body cams when their framerate is limited.
- Added API functionality to track when body cams are created and destroyed.
- Added an API flag to body cams to determine whether they should be considered wirelessly connected to the ship.
Version 2.2.4
- Prevented the vanilla first person arms from showing in body cams when using a viewmodel replacement through ModelReplacementAPI.
Version 2.2.3
- Prevented an error that could occur when creating the terminal PiP body cam command alongside darmuhsTerminalStuff v3.5.0.
Version 2.2.2
- Fixed visibility issues when viewing a dead player's perspective through a body cam.
- Prevented a NullReferenceException that could occur if the terminal tried to load a null node.
Version 2.2.1
- Fixed an issue that prevented body cams created by API users from displaying output when attached to arbitrary objects.
- Added a feature to allow API users to hide any set of renderers they choose.
Version 2.2.0
- Implemented switching perspectives for flashlights held by players viewed by body cams. Flashlights that are in the view player's hand will now emit light from the item instead of the helmet light that is used in third person.
Version 2.1.2
- Fixed centipede tracking thinking a centiped was clinged to two players at once if two clients send messages that they are being clinged at the same time. This is likely the cause of the issue that was worked around in 2.1.1.
Version 2.1.1
- Tentatively fixed NullReferenceExceptions which could occur when a centipede clings to a player's head.
- Prevented NullReferenceExceptions when running LethalPipeRemoval to destroy the door screen.
Version 2.1.0
- Modified the HorizontalResolution option to only affect the main body cam. API users can now set the
Resolution
property to override the default resolution of 160x120.
Version 2.0.6
- Prevented a NullReferenceException when API users (TwoRadarMaps, darmuhsTerminalStuff) create a body cam that is synchronized with a radar map.
- Removed the warning that
DisplayOriginalScreenWhenDisabled
will not work when GeneralImprovements's UseBetterMonitors is enabled.
Version 2.0.5
- Added support for falling back to GeneralImprovements's monitor assignments when the body cam is disabled.
- Fixed the monitor index ordering with GeneralImprovements's
UseBetterMonitors
on andAddMoreBetterMonitors
off.
Version 2.0.4
- Fixed an error that could occur when darmuhsTerminalStuff tried to create a body cam, caused by some debug logging that is now removed.
- Added a tip upon the first load into a game on 2.0.4 to notify users that the body cams are a ship upgrade now.
Version 2.0.3
- Prevented error spam that would occur when a body cam switches from targeting a solo player to targeting nothing.
- Fixed a long-standing issue where the body cam would not switch back on if it was targeting a dead player with no corpse while players respawned.
- Fixed invalid targets sometimes displaying on the body cam after the 2.0.0 update.
- Only disable the main body cam based on the EnableCamera option, and exclude any body cams created by API users.
Version 2.0.2
- Fixed the antenna prefab not spawning on clients.
Version 2.0.1
- Switched the default value for the ship upgrade option to be true by default as it was intended to be in 2.0.0. Old values will be migrated.
- Fixed a compatibility issue with darmuhsTerminalStuff's minicams command.
- Prevented errors that would occur when the debugging options are enabled.
Version 2.0.0 (requires v50)
- Added a ship upgrade to enable body cams for 200 credits which is enabled by default if LethalLib is installed.
- Added support for adjusting the position of tulip snakes and snare fleas based on the view perspective.
- Added support for vanilla cosmetics (bunny ears, bee antennae).
- The screen that the body cam occupies will now switch back to the camera that originally displayed when the body cam is invalid, when GeneralImprovements's UseBetterMonitors is not enabled.
- Added an option to swap the external and internal cameras' positions when GeneralImprovements's UseBetterMonitors is not enabled.
- Added an option to modify the external camera screen's emissive color.
- Fixed an issue where the radar map's night vision light would be visible on body cams when CullFactory is enabled.
- The camera that is replaced by the body cam will now be disabled to improve performance.
- Allowed API users to override a body cam's resolution and DisableCameraWhileTargetIsOnShip option.
Version 1.3.0
- Fixed a long-standing issue where MoreCompany cosmetics being destroyed on a masked enemy would cause a freeze.
- Significantly reworked how cosmetics are updated. These changes may introduce old or new bugs, please report them on GitHub.
Version 1.2.11
- Fixed error spam that would occur when the Advanced Company light shoes curse was lifted.
Version 1.2.10
- Prevent errors when body cams are immediately destroyed between setting and resetting the perspective.
Version 1.2.9
- Fixed a freeze/error spam that would occur if MoreCompany encountered an error while syncing cosmetics.
Version 1.2.8
- Fixed the green transition animation becoming permanently frozen on the body cam screen if
UseTargetTransitionAnimation
was disabled.
Version 1.2.7
- Fixed the green transition appearing on the player's view when switching from a dead body or mimic to that player. The transition could remain visible until the target was switched again if
DisableCameraWhileTargetIsOnShip
was enabled. - Allowed
DisableCameraWhileTargetIsOnShip
to disable body cams based on whether other targets types (corpses, masked players, and radar boosters) are on the ship.
Version 1.2.6
- Fixed the body cam not powering back on after the monitors are turned off.
Version 1.2.5
- Fixed an error that would occur if the door screen was destroyed.
Version 1.2.4
- Fixed disabling the transition animation causing the green rectangle to get stuck on the body cam screen. Note that this probably doesn't fix issue #23.
Version 1.2.3
- Optimized some hot code which may help performance very slightly.
Version 1.2.2
- Added two options to allow collection of useful debug information if error spam is encountered, information which should point directly to the problematic mod. More information is available in the readme.
- Prevented cosmetics from being collected from other mods if they have been destroyed. Not sure if this has been hit in the wild, but this may prevent some error spam.
Version 1.2.1
- Fixed an error that would occur when exiting to the menu and starting a game again with the picture-in-picture body cam enabled.
Version 1.2.0
- Added an opt-in
view bodycam
command to the terminal to display a picture-in-picture view of the bodycam. TwoRadarMaps v1.2.0 will use a separate bodycam when the feature is enabled. - Developer features: Added an API to force a body cam to render, and allowed body cams to function without being attached to a renderer's visibility/materials.
Version 1.1.6
- (Tentatively) fixed an error that could softlock the ship when viewing a player with a custom ragdoll. This could occur when a player was killed by Herobrine mod.
Version 1.1.5
- Fixed error spam that would occur when changing AdvancedCompany cosmetics.
- Made the PrintCosmeticsDebugInfo option work when enabled at startup.
Version 1.1.4
- Added an option to disable the green flash animation displayed when changing targets on the body cam.
- HDLethalCompany graphics options will now apply to the body cam.
Version 1.1.3
- Fixed compatibility for MoreCompany versions greater than 1.8.0. Note that there appears to be an issue where upon joining a server, cosmetics may appear blocking the view of the body cam, which may be caused by an error in MoreCompany.
Version 1.1.2
- Fixed error spam that could occur when changing models with ModelReplacementAPI.
- Added a debug option that prints extra information about which cosmetics are being collected for each player, and the reason they are being collected. If you have issues with cosmetics/model replacements, I may ask for you to enable this to get new logs.
Version 1.1.1
- Hopefully prevented an issue where in rare cases, masked players being viewed by the body cam would cause the screen to freeze. This was perhaps caused by other mods deleting renderers attached to the masked players after they were created.
Version 1.1.0
- Refactored the mod to allow creation of multiple body cams through an API. This feature is not used in OpenBodyCams, but may be used in the future to provide a separate body cam for the terminal, or other use cases.
- When no valid target is selected (i.e. when players are still respawning), the screen will now display nothing, but it will remain illuminated to indicate that it is still powered.
- Fixed an issue where the screen would get frozen with the green transition visible when a radar booster is left behind on a planet.
- Note: Due to refactoring much of the code that reacts to the events in the game, I'm anticipating there may be regressions in the way the body cam tracks its target's status changes (death, masking, respawning). If the camera gets stuck displaying something unexpected, please report that (preferably through a GitHub issue) with steps to reproduce the problem.
Version 1.0.24
- Added support for ModelReplacementAPI's third person model replacements.
- Added support for LethalVRM's third person model replacements.
Version 1.0.23
- Fixed the external camera staying frozen when looking at the screen by the door controls.
Version 1.0.22
- Added handling of AdvancedCompany equipment to the compatibility feature, preventing equipped items from obstructing the body cam.
Version 1.0.21
- Fixed all cameras in the ship staying enabled when looking away from the front of the ship with DisableInternalShipCamera off. The internal camera is disabled if its screen is not visible to any camera but its own, which occurs when it is not visible to the player.
Version 1.0.20
- Fixed parsing of the emissive color option in locales that use
,
as their decimal separator.
Version 1.0.19
- Added an option to adjust the emissive color of the body cam screen.
- Added an option for the panning speed for cameras when attached to a radar booster. When set to 0, the camera will be stationary and face in the direction the player was looking when placing the radar booster.
- Implemented an optional fix for dropped item rotation being desynced between the player dropping the item and other players. This will affect all items in the game. Without this fix, radar boosters will not face in the direction that they were dropped by the player that had been holding them.
- Allowed the camera to be disabled when the player being viewed enters the ship to avoid rendering the items on board twice.
Version 1.0.18
- Fixed the radar map not disabling correctly when it was not visible, or while the player is outside the ship.
Version 1.0.17
- Fixed body cams being unable to display on the GeneralImprovements large monitors with UseBetterMonitors enabled.
Version 1.0.16
- Fixed a reduction in performance that began in version 1.0.14 with the fix for the DisableInternalShipCamera bug.
Version 1.0.15
- Updated GeneralImprovements compatibility to work with version 1.1.1. This updated compatibility will not work with any previous versions of GeneralImprovements.
Version 1.0.14
- Fixed a bug that caused error spam when MoreCompany compatibility was being used.
- Forced the radar map to keep rendering when interacting with the terminal while the DisableInternalShipCamera option is enabled.
Version 1.0.13
- Supported the GeneralImprovements UseBetterMonitors option with a config option to select the monitor number to display the body cam on.
Version 1.0.12
- Stopped placing the body cam on the monitor by the door.
- Reduced the emissivity of the bodycam monitor.
Version 1.0.11
- Added an option to turn the body cam screen off, which can be used in-game if performance issues are encountered.
Version 1.0.10
- Added support for AdvancedCompany cosmetics. They should now be hidden on the body cam when viewing other players.
Version 1.0.9
- Made the bodycam monitor turn off when the radar map is powered down by the button or a lightning strike.
Version 1.0.8
- Added an option to adjust the brightness of the night vision light. This can be used to counteract the green tint of the screen making it difficult to see when players are in dark areas.
Version 1.0.7
- Fixed a compatibility issue with Immersive Visor which would cause the body cam to render to the screen instead of a texture when a player respawned.
- Prevented the radar map's night vision light from showing up on the body cam.
Version 1.0.6
- Prevented MoreCompany cosmetics from appearing and obstructing the view when joining a game with the camera viewing someone with cosmetics equipped.
- Made the body cam attach to dead bodies on clients other than the one of the player that died.
Version 1.0.5
- Fixed an compatibility issue with MirrorDecor that caused the first person arms to be invisible in the body cam.
Version 1.0.4
- Fixed an issue where the local player's body would be invisible in the body cam with LethalEmotesAPI or MirrorDecor installed.
Version 1.0.3
- Fixed an error that would occur when a third person emote was started by the LethalEmotesAPI mod.
- Added a config option to disable MoreCompany cosmetic support that can be used if compatibility issues arise.
Version 1.0.2
- Fixed error spam that would occur if the camera was attached to an enemy or dead body being destroyed after a round ends.
Version 1.0.1
- Fixed an error that would occur when MoreCompany is not installed.
Version 1.0.0
- Initial release.