Skip to content
Open
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions Assets/BetterPhysics/Runtime/Scripts/BetterRigidbody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public void SetLimit(int index, SpeedLimit limit) {
public int LimitCount => limits.Count;

private void FixedUpdate() {
if (!_rb.isKinematic) {
if (!_rb.isKinematic && _exemptedVelocityChange != Vector3.zero) {
// Apply exempted newtons directly to the velocity
_rb.AddLinearVelocity(_exemptedVelocityChange);
_exemptedVelocityChange = Vector3.zero;
}
Comment on lines +63 to 64

Copilot AI Apr 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current condition may prevent _exemptedVelocityChange from being reset when _rb.isKinematic is true, potentially leaving stale data for future frames. Consider resetting _exemptedVelocityChange outside the conditional block to ensure it is always cleared.

Suggested change
_exemptedVelocityChange = Vector3.zero;
}
}
_exemptedVelocityChange = Vector3.zero;

Copilot uses AI. Check for mistakes.
_exemptedVelocityChange = Vector3.zero;

ApplyLimits();
}
Expand Down Expand Up @@ -838,4 +838,4 @@ private Vector3 CalculateVelocityChangeWithSoftLimit(in Vector3 currentVelocity,

#endregion
}
}
}