diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-12-10 15:52:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 15:52:02 +0100 |
commit | f675b6b6237696788df1ad9c1f2d9f3d2b025352 (patch) | |
tree | c1ff204bb81270d834e72c43b486f97e61f0f519 /scene/3d | |
parent | 7658868616909822b880c6b4c0dba4ae68e823ad (diff) | |
parent | 0c352407d8e7d3c8eb3108a734b5a9746ea14ad7 (diff) |
Merge pull request #55723 from rydergaming/get-colliding-body-vehiclewheel
VehicleWheel can now return the surface it's colliding with.
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/vehicle_body_3d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/vehicle_body_3d.h | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index 90db093137..5b2d01f8df 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -225,6 +225,10 @@ bool VehicleWheel3D::is_in_contact() const { return m_raycastInfo.m_isInContact; } +Node3D *VehicleWheel3D::get_contact_body() const { + return m_raycastInfo.m_groundObject; +} + 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); @@ -257,6 +261,7 @@ void VehicleWheel3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_friction_slip"), &VehicleWheel3D::get_friction_slip); 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("set_roll_influence", "roll_influence"), &VehicleWheel3D::set_roll_influence); ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel3D::get_roll_influence); @@ -413,9 +418,8 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) { ray_params.exclude = exclude; ray_params.collision_mask = get_collision_mask(); - bool col = ss->intersect_ray(ray_params, rr); - wheel.m_raycastInfo.m_groundObject = nullptr; + bool col = ss->intersect_ray(ray_params, rr); if (col) { param = source.distance_to(rr.position) / source.distance_to(target); diff --git a/scene/3d/vehicle_body_3d.h b/scene/3d/vehicle_body_3d.h index a798c76c1f..eb6923df54 100644 --- a/scene/3d/vehicle_body_3d.h +++ b/scene/3d/vehicle_body_3d.h @@ -129,6 +129,8 @@ public: bool is_in_contact() const; + Node3D *get_contact_body() const; + void set_roll_influence(real_t p_value); real_t get_roll_influence() const; |