Skip to content

Commit

Permalink
Don't GetComponent for part.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Nov 5, 2023
1 parent f02cdc4 commit 807e5aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/VesselModuleRotationRO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ private void ApplyAngularVelocity()
// Applying force on every part
foreach (Part p in vessel.parts)
{
if (!p.GetComponent<Rigidbody>()) continue;
p.GetComponent<Rigidbody>().AddTorque(angVel, ForceMode.VelocityChange);
p.GetComponent<Rigidbody>().AddForce(Vector3.Cross(angVel, (p.transform.position - COM)), ForceMode.VelocityChange);
if (p.rb == null || p.rb.isKinematic) continue;
p.rb.AddTorque(angVel, ForceMode.VelocityChange);
p.rb.AddForce(Vector3.Cross(angVel, (p.transform.position - COM)), ForceMode.VelocityChange);

// Doing this through rigidbody is deprecated but I can't find a reliable way to use the 1.2 part.addforce/addtorque so they provide reliable results
// see 1.2 patchnotes and unity docs for ForceMode.VelocityChange/ForceMode.Force
Expand Down

0 comments on commit 807e5aa

Please sign in to comment.