From 97da9f14abfbbfd8a27f12afef0cd7c46fa425a6 Mon Sep 17 00:00:00 2001 From: Agustin Benavidez Date: Sat, 21 May 2016 06:35:55 -0300 Subject: Add get_linear_velocity() method to VehicleBody class Doc added also. --- scene/3d/vehicle_body.cpp | 8 +++++++- scene/3d/vehicle_body.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index ba30c118f0..6eadc71d63 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -936,7 +936,7 @@ void VehicleBody::_direct_state_changed(Object *p_state) { wheel.m_deltaRotation *= real_t(0.99);//damping of rotation when not in contact } - + linear_velocity = s->get_linear_velocity(); } void VehicleBody::set_mass(real_t p_mass) { @@ -990,6 +990,10 @@ float VehicleBody::get_steering() const{ return m_steeringValue; } +Vector3 VehicleBody::get_linear_velocity() +{ + return linear_velocity; +} void VehicleBody::_bind_methods(){ @@ -1008,6 +1012,8 @@ void VehicleBody::_bind_methods(){ ObjectTypeDB::bind_method(_MD("set_steering","steering"),&VehicleBody::set_steering); ObjectTypeDB::bind_method(_MD("get_steering"),&VehicleBody::get_steering); + ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&VehicleBody::get_linear_velocity); + ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&VehicleBody::_direct_state_changed); ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/engine_force",PROPERTY_HINT_RANGE,"0.00,1024.0,0.01"),_SCS("set_engine_force"),_SCS("get_engine_force")); diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index 285cca142d..a026a10dff 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -177,7 +177,8 @@ public: void set_steering(float p_steering); float get_steering() const; - + + Vector3 get_linear_velocity(); VehicleBody(); }; -- cgit v1.2.3 From da24bc8f3fa5bb00deb7042b63794f4218dee774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 21 May 2016 11:52:21 +0200 Subject: VehicleBody: Cosmetic fixes to previous commit --- scene/3d/vehicle_body.cpp | 2 +- scene/3d/vehicle_body.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 6eadc71d63..e35ba11e84 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -992,7 +992,7 @@ float VehicleBody::get_steering() const{ Vector3 VehicleBody::get_linear_velocity() { - return linear_velocity; + return linear_velocity; } void VehicleBody::_bind_methods(){ diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index a026a10dff..b6ad88f15e 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -177,7 +177,7 @@ public: void set_steering(float p_steering); float get_steering() const; - + Vector3 get_linear_velocity(); VehicleBody(); -- cgit v1.2.3