Skip to content

Commit

Permalink
fix viewing nav slowing shuttle down (space-wizards#32381)
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
Ilya246 authored Nov 19, 2024
1 parent dffece4 commit 909235c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Content.Server/Physics/Controllers/MoverController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ private void HandleShuttleMovement(float frameTime)
var linearInput = Vector2.Zero;
var brakeInput = 0f;
var angularInput = 0f;
var linearCount = 0;
var brakeCount = 0;
var angularCount = 0;

foreach (var (pilotUid, pilot, _, consoleXform) in pilots)
{
Expand All @@ -322,24 +325,27 @@ private void HandleShuttleMovement(float frameTime)
if (brakes > 0f)
{
brakeInput += brakes;
brakeCount++;
}

if (strafe.Length() > 0f)
{
var offsetRotation = consoleXform.LocalRotation;
linearInput += offsetRotation.RotateVec(strafe);
linearCount++;
}

if (rotation != 0f)
{
angularInput += rotation;
angularCount++;
}
}

var count = pilots.Count;
linearInput /= count;
angularInput /= count;
brakeInput /= count;
// Don't slow down the shuttle if there's someone just looking at the console
linearInput /= Math.Max(1, linearCount);
angularInput /= Math.Max(1, angularCount);
brakeInput /= Math.Max(1, brakeCount);

// Handle shuttle movement
if (brakeInput > 0f)
Expand Down

0 comments on commit 909235c

Please sign in to comment.