Freecam Controls Toggle (#4)

Added option to toggle Freecam Controls using a new keybind (default: keypad period).

This allows users to easily switch to Freecam mode, move their camera to position, toggle camera controls, and move the player character. Great addition for efficient testing of weight painting and animations.

Reviewed-on: #4
Co-authored-by: GrooveypenguinX <grooveypenguinx@noreply.dev.sp-tarkov.com>
Co-committed-by: GrooveypenguinX <grooveypenguinx@noreply.dev.sp-tarkov.com>
This commit is contained in:
GrooveypenguinX 2024-03-03 13:40:33 +00:00 committed by Terkoiz
parent 28fd27d21d
commit 027893c1d6
2 changed files with 31 additions and 0 deletions

View File

@ -60,6 +60,11 @@ namespace Terkoiz.Freecam
ToggleCamera(); ToggleCamera();
} }
if (FreecamPlugin.ToggleFreecamControls.Value.IsDown())
{
ToggleCameraControls();
}
if (FreecamPlugin.TeleportToCamera.Value.IsDown()) if (FreecamPlugin.TeleportToCamera.Value.IsDown())
{ {
MovePlayerToCamera(); MovePlayerToCamera();
@ -196,6 +201,25 @@ namespace Terkoiz.Freecam
localPlayer.PointOfView = EPointOfView.FirstPerson; localPlayer.PointOfView = EPointOfView.FirstPerson;
} }
/// <summary>
/// A helper method to toggle the Freecam Camera Controls
/// </summary>
private void ToggleCameraControls()
{
if (_freeCamScript.IsActive)
{
_freeCamScript.IsActive = false;
_gamePlayerOwner.enabled = true;
}
else
{
_freeCamScript.IsActive = true;
_gamePlayerOwner.enabled = false;
}
}
/// <summary> /// <summary>
/// Gets the current <see cref="Player"/> instance if it's available /// Gets the current <see cref="Player"/> instance if it's available
/// </summary> /// </summary>

View File

@ -20,6 +20,7 @@ namespace Terkoiz.Freecam
// Keyboard shortcut config entries // Keyboard shortcut config entries
private const string KeybindSectionName = "Keybinds"; private const string KeybindSectionName = "Keybinds";
internal static ConfigEntry<KeyboardShortcut> ToggleFreecamMode; internal static ConfigEntry<KeyboardShortcut> ToggleFreecamMode;
internal static ConfigEntry<KeyboardShortcut> ToggleFreecamControls;
internal static ConfigEntry<KeyboardShortcut> TeleportToCamera; internal static ConfigEntry<KeyboardShortcut> TeleportToCamera;
internal static ConfigEntry<KeyboardShortcut> ToggleUi; internal static ConfigEntry<KeyboardShortcut> ToggleUi;
@ -67,6 +68,12 @@ namespace Terkoiz.Freecam
new KeyboardShortcut(KeyCode.KeypadPlus), new KeyboardShortcut(KeyCode.KeypadPlus),
"The keyboard shortcut that toggles Freecam"); "The keyboard shortcut that toggles Freecam");
ToggleFreecamControls = Config.Bind(
KeybindSectionName,
"Toggle Freecam Controls",
new KeyboardShortcut(KeyCode.KeypadPeriod),
"The keyboard shortcut that toggles Freecam Controls");
TeleportToCamera = Config.Bind( TeleportToCamera = Config.Bind(
KeybindSectionName, KeybindSectionName,
"Teleport To Camera", "Teleport To Camera",