Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose contact point and contact normal on VehicleWheel3D to scripting. #93900

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions doc/classes/VehicleWheel3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
Returns [code]null[/code] if the wheel is not in contact with a surface, or the contact body is not a [PhysicsBody3D].
</description>
</method>
<method name="get_contact_normal" qualifiers="const">
<return type="Vector3" />
<description>
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.
</description>
</method>
<method name="get_contact_point" qualifiers="const">
<return type="Vector3" />
<description>
Returns the point of the suspension's collision in world space if the wheel is in contact. If the wheel isn't in contact with anything, returns the maximum point of the wheel's ray cast in world space, which is defined by [code]wheel_rest_length + wheel_radius[/code].
</description>
</method>
<method name="get_rpm" qualifiers="const">
<return type="float" />
<description>
Expand Down
10 changes: 10 additions & 0 deletions scene/3d/physics/vehicle_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ bool VehicleWheel3D::is_in_contact() const {
return m_raycastInfo.m_isInContact;
}

Vector3 VehicleWheel3D::get_contact_point() const {
return m_raycastInfo.m_contactPointWS;
}

Vector3 VehicleWheel3D::get_contact_normal() const {
return m_raycastInfo.m_contactNormalWS;
}

Node3D *VehicleWheel3D::get_contact_body() const {
return m_raycastInfo.m_groundObject;
}
Expand Down Expand Up @@ -256,6 +264,8 @@ void VehicleWheel3D::_bind_methods() {

ClassDB::bind_method(D_METHOD("is_in_contact"), &VehicleWheel3D::is_in_contact);
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("set_roll_influence", "roll_influence"), &VehicleWheel3D::set_roll_influence);
ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel3D::get_roll_influence);
Expand Down
4 changes: 4 additions & 0 deletions scene/3d/physics/vehicle_body_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ class VehicleWheel3D : public Node3D {

bool is_in_contact() const;

Vector3 get_contact_point() const;

Vector3 get_contact_normal() const;

Node3D *get_contact_body() const;

void set_roll_influence(real_t p_value);
Expand Down
Loading