Skip to content

Commit b2a409d

Browse files
committed
fix(PlayerControllerRBBase): public configuarable smoothingFactor
1 parent fa20294 commit b2a409d

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Assets/Mirror/Examples/PlayerTest/Rigidbody/PlayerRBHybrid.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ MonoBehaviour:
437437
syncDirection: 1
438438
syncMode: 0
439439
syncInterval: 0
440-
updateMethod: 1
441440
target: {fileID: 5650773562400175449}
441+
updateMethod: 1
442442
syncPosition: 1
443443
syncRotation: 1
444444
syncScale: 0
@@ -494,6 +494,7 @@ MonoBehaviour:
494494
maxMoveSpeed: 8
495495
inputSensitivity: 2
496496
inputGravity: 2
497+
smoothingFactor: 10
497498
maxTurnSpeed: 100
498499
turnAcceleration: 3
499500
initialJumpSpeed: 2.5

Assets/Mirror/Examples/PlayerTest/Rigidbody/PlayerRBReliable.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ MonoBehaviour:
437437
syncDirection: 1
438438
syncMode: 0
439439
syncInterval: 0
440-
updateMethod: 1
441440
target: {fileID: 5650773562400175449}
441+
updateMethod: 1
442442
syncPosition: 1
443443
syncRotation: 1
444444
syncScale: 0
@@ -492,6 +492,7 @@ MonoBehaviour:
492492
maxMoveSpeed: 8
493493
inputSensitivity: 2
494494
inputGravity: 2
495+
smoothingFactor: 10
495496
maxTurnSpeed: 100
496497
turnAcceleration: 3
497498
initialJumpSpeed: 2.5

Assets/Mirror/Examples/PlayerTest/Rigidbody/PlayerRBUnreliable.prefab

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ MonoBehaviour:
433433
m_Script: {fileID: 11500000, guid: a553cb17010b2403e8523b558bffbc14, type: 3}
434434
m_Name:
435435
m_EditorClassIdentifier:
436-
syncMethod: 1
436+
syncMethod: 0
437437
syncDirection: 1
438438
syncMode: 0
439439
syncInterval: 0
440-
updateMethod: 1
441440
target: {fileID: 6814142693731383418}
441+
updateMethod: 1
442442
syncPosition: 1
443443
syncRotation: 1
444444
syncScale: 0
@@ -453,7 +453,6 @@ MonoBehaviour:
453453
showOverlay: 0
454454
overlayColor: {r: 0, g: 0, b: 0, a: 0.5}
455455
bufferResetMultiplier: 3
456-
useFixedUpdate: 1
457456
positionSensitivity: 0.01
458457
rotationSensitivity: 0.01
459458
scaleSensitivity: 0.01
@@ -493,6 +492,7 @@ MonoBehaviour:
493492
maxMoveSpeed: 8
494493
inputSensitivity: 2
495494
inputGravity: 2
495+
smoothingFactor: 10
496496
maxTurnSpeed: 100
497497
turnAcceleration: 3
498498
initialJumpSpeed: 2.5

Assets/Mirror/Examples/_Common/Controllers/PlayerControllerRB/PlayerControllerRBBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public enum ControlOptions : byte
9494
[Tooltip("Gravity factors into decelleration")]
9595
public float inputGravity = 2f;
9696

97+
[Range(2, 20f)]
98+
[Tooltip("Smoothing factor for movement velocity\nLower is more affected by physics")]
99+
public float smoothingFactor = 10f;
100+
97101
[Header("Turning")]
98102
[Range(0, 300f)]
99103
[Tooltip("Max Rotation in degrees per second")]
@@ -526,7 +530,6 @@ void ApplyMove(float fixedDeltaTime)
526530
currentVelocity = rigidBody.velocity;
527531
#endif
528532

529-
float smoothingFactor = 10f; // Adjust this for smoother/faster transitions
530533
Vector3 smoothedVelocity = Vector3.Lerp(currentVelocity, targetVelocity, smoothingFactor * fixedDeltaTime);
531534

532535
#if UNITY_6000_0_OR_NEWER

0 commit comments

Comments
 (0)