Skip to content

Commit

Permalink
fix suspension length miscalculation
Browse files Browse the repository at this point in the history
  • Loading branch information
betalars committed Feb 29, 2024
1 parent b5d30f9 commit cc64c71
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions scene/3d/physics/vehicle_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
Vector3 source = wheel.m_raycastInfo.m_hardPointWS;
wheel.m_raycastInfo.m_contactPointWS = source + rayvector;
const Vector3 &target = wheel.m_raycastInfo.m_contactPointWS;
source -= wheel.m_wheelRadius * wheel.m_raycastInfo.m_wheelDirectionWS;

real_t param = real_t(0.);

Expand All @@ -425,8 +424,7 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
wheel.m_raycastInfo.m_groundObject = Object::cast_to<PhysicsBody3D>(rr.collider);
}

real_t hitDistance = param * raylen;
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
wheel.m_raycastInfo.m_suspensionLength = source.distance_to(rr.position) - wheel.m_wheelRadius;
//clamp on max suspension travel

real_t minSuspensionLength = wheel.m_suspensionRestLength - wheel.m_maxSuspensionTravel;
Expand Down

0 comments on commit cc64c71

Please sign in to comment.