diff --git a/doc/classes/VehicleWheel3D.xml b/doc/classes/VehicleWheel3D.xml index dee096a52e63..b8c5f5547e69 100644 --- a/doc/classes/VehicleWheel3D.xml +++ b/doc/classes/VehicleWheel3D.xml @@ -24,6 +24,12 @@ Returns the normal of the suspension's collision in world space if the wheel is in contact. If the wheel isn't in contact with anything, returns a vector pointing directly along the suspension axis toward the vehicle in world space. + + + + Returns the magnitude of the normal force at the wheel's contact point with the ground in Newtons (N). This represents the perpendicular force exerted by the surface on the wheel. Use [method get_contact_normal] to get the direction of this force. Returns [code]0.0[/code] if the wheel is not in contact with any surface. + + diff --git a/scene/3d/physics/vehicle_body_3d.cpp b/scene/3d/physics/vehicle_body_3d.cpp index 5efa207f2486..cc3490d126c3 100644 --- a/scene/3d/physics/vehicle_body_3d.cpp +++ b/scene/3d/physics/vehicle_body_3d.cpp @@ -267,6 +267,10 @@ Node3D *VehicleWheel3D::get_contact_body() const { return m_raycastInfo.m_groundObject; } +real_t VehicleWheel3D::get_contact_normal_force() const { + return m_wheelsSuspensionForce; +} + void VehicleWheel3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel3D::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel3D::get_radius); @@ -302,6 +306,7 @@ void VehicleWheel3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_contact_body"), &VehicleWheel3D::get_contact_body); ClassDB::bind_method(D_METHOD("get_contact_point"), &VehicleWheel3D::get_contact_point); ClassDB::bind_method(D_METHOD("get_contact_normal"), &VehicleWheel3D::get_contact_normal); + ClassDB::bind_method(D_METHOD("get_contact_normal_force"), &VehicleWheel3D::get_contact_normal_force); ClassDB::bind_method(D_METHOD("set_roll_influence", "roll_influence"), &VehicleWheel3D::set_roll_influence); ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel3D::get_roll_influence); diff --git a/scene/3d/physics/vehicle_body_3d.h b/scene/3d/physics/vehicle_body_3d.h index 21614309a1c5..0b0cb26256b6 100644 --- a/scene/3d/physics/vehicle_body_3d.h +++ b/scene/3d/physics/vehicle_body_3d.h @@ -178,6 +178,8 @@ class VehicleWheel3D : public Node3D { real_t get_skidinfo() const; + real_t get_contact_normal_force() const; + real_t get_rpm() const; void set_engine_force(real_t p_engine_force);