Selaa lähdekoodia

GDScript can now tell if the wheel is in contact with the ground; change roll influence of the wheel in editor

Zireael07 8 vuotta sitten
vanhempi
commit
307c5c1afc
2 muutettua tiedostoa jossa 23 lisäystä ja 0 poistoa
  1. 18 0
      scene/3d/vehicle_body.cpp
  2. 5 0
      scene/3d/vehicle_body.h

+ 18 - 0
scene/3d/vehicle_body.cpp

@@ -214,6 +214,18 @@ float VehicleWheel::get_friction_slip() const {
 	return m_frictionSlip;
 }
 
+void VehicleWheel::set_roll_influence(float p_value) {
+	m_rollInfluence = p_value;
+}
+
+float VehicleWheel::get_roll_influence() const {
+	return m_rollInfluence;
+}
+
+bool VehicleWheel::is_in_contact() const {
+	return m_raycastInfo.m_isInContact;
+}
+
 void VehicleWheel::_bind_methods() {
 
 	ObjectTypeDB::bind_method(_MD("set_radius", "length"), &VehicleWheel::set_radius);
@@ -246,8 +258,14 @@ void VehicleWheel::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("set_friction_slip", "length"), &VehicleWheel::set_friction_slip);
 	ObjectTypeDB::bind_method(_MD("get_friction_slip"), &VehicleWheel::get_friction_slip);
 
+	ObjectTypeDB::bind_method(_MD("is_in_contact"), &VehicleWheel::is_in_contact);
+
+	ObjectTypeDB::bind_method(_MD("set_roll_influence", "roll_influence"), &VehicleWheel::set_roll_influence);
+	ObjectTypeDB::bind_method(_MD("get_roll_influence"), &VehicleWheel::get_roll_influence);
+
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "type/traction"), _SCS("set_use_as_traction"), _SCS("is_used_as_traction"));
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "type/steering"), _SCS("set_use_as_steering"), _SCS("is_used_as_steering"));
+	ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/roll_influence"), _SCS("set_roll_influence"), _SCS("get_roll_influence"));
 	ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/radius"), _SCS("set_radius"), _SCS("get_radius"));
 	ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/rest_length"), _SCS("set_suspension_rest_length"), _SCS("get_suspension_rest_length"));
 	ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/friction_slip"), _SCS("set_friction_slip"), _SCS("get_friction_slip"));

+ 5 - 0
scene/3d/vehicle_body.h

@@ -126,6 +126,11 @@ public:
 	void set_use_as_steering(bool p_enabled);
 	bool is_used_as_steering() const;
 
+	bool is_in_contact() const;
+
+	void set_roll_influence(float p_value);
+	float get_roll_influence() const;
+
 	VehicleWheel();
 };