Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace RobotecSpectatorCamera
}
}

if ((m_isRightMouseButtonPressed || m_configuration.m_cameraMode == CameraMode::FreeFlying) &&
if (m_configuration.m_cameraMode == CameraMode::ThirdPerson && m_isRightMouseButtonPressed &&
(channelId == AzFramework::InputDeviceMouse::Movement::X || channelId == AzFramework::InputDeviceMouse::Movement::Y))
{
if (m_ignoreNextMovement)
Expand All @@ -177,7 +177,7 @@ namespace RobotecSpectatorCamera

if (m_centerTheCursor)
{
const auto center = AZ::Vector2(0.5f, 0.5f);
const AZ::Vector2 center(0.5f, 0.5f);

// Recenter the cursor to avoid edge constraints
AzFramework::InputSystemCursorRequestBus::Event(
Expand All @@ -193,6 +193,29 @@ namespace RobotecSpectatorCamera

RotateCameraOnMouse(mouseDelta);
}

if (m_configuration.m_cameraMode == CameraMode::FreeFlying &&
(channelId == AzFramework::InputDeviceMouse::Movement::X || channelId == AzFramework::InputDeviceMouse::Movement::Y))
{
// Scale is needed because the mouseDelta for ThirdPerson mode uses a normalized cursor position, resulting in small differences
// between events. However, the FreeFlying mode uses the value directly from the input channel, which appears to be in pixels.
// Therefore, the calculated mouse delta is much bigger. Without this parameter, the camera rotation speed in FreeFlying mode is
// so high that the spectator camera becomes almost useless. The value of the scale was chosen arbitrarily.
constexpr float mouseDeltaScale = 0.002f;

AZ::Vector2 mouseDelta = AZ::Vector2::CreateZero();

if (channelId == AzFramework::InputDeviceMouse::Movement::X)
{
mouseDelta.SetX(inputChannel.GetValue() * mouseDeltaScale);
}
else
{
mouseDelta.SetY(inputChannel.GetValue() * mouseDeltaScale);
}

RotateCameraOnMouse(mouseDelta);
}
}

void SpectatorCameraComponent::KeyboardEvent(const AzFramework::InputChannel& inputChannel)
Expand Down
2 changes: 1 addition & 1 deletion Gems/RobotecSpectatorCamera/gem.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"gem_name": "RobotecSpectatorCamera",
"version": "1.0.0",
"version": "1.0.1",
"display_name": "RobotecSpectatorCamera",
"license": "Apache-2.0",
"license_url": "https://opensource.org/licenses/Apache-2.0",
Expand Down
Loading