Adjust steering of vehicles

soundtrack
Ensar Sarajčić 2021-11-20 19:32:26 +01:00
parent 4e8344c485
commit b0d93d074c
3 changed files with 8 additions and 9 deletions

View File

@ -45,7 +45,9 @@ rings = 3
mass = 175.0 mass = 175.0
script = ExtResource( 1 ) script = ExtResource( 1 )
max_steer_angle = 18.0 max_steer_angle = 18.0
max_steer_speed = 75.0 speed_steer_angle = 8.0
max_steer_speed = 60.0
max_steer_input = 60.0
max_engine_force = 100.0 max_engine_force = 100.0
max_brake_force = 60.0 max_brake_force = 60.0
base_engine_pitch = 0.38 base_engine_pitch = 0.38

View File

@ -1,9 +1,12 @@
[gd_scene load_steps=15 format=2] [gd_scene load_steps=16 format=2]
[ext_resource path="res://vehicles/tire_smoke.tscn" type="PackedScene" id=1] [ext_resource path="res://vehicles/tire_smoke.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/bugmobile.glb" type="PackedScene" id=2] [ext_resource path="res://assets/bugmobile.glb" type="PackedScene" id=2]
[ext_resource path="res://vehicles/vehicle.gd" type="Script" id=3] [ext_resource path="res://vehicles/vehicle.gd" type="Script" id=3]
[sub_resource type="Curve" id=21]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.811321, 0.836364 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.581818 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="Curve" id=18] [sub_resource type="Curve" id=18]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.179245, 0.584091 ), -0.306612, -0.306612, 0, 0, Vector2( 0.603774, 0.954545 ), 0.0, 0.0, 0, 0, Vector2( 0.806604, 0.989773 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ] _data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.179245, 0.584091 ), -0.306612, -0.306612, 0, 0, Vector2( 0.603774, 0.954545 ), 0.0, 0.0, 0, 0, Vector2( 0.806604, 0.989773 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
@ -54,6 +57,7 @@ mass = 600.0
script = ExtResource( 3 ) script = ExtResource( 3 )
max_steer_angle = 20.0 max_steer_angle = 20.0
speed_steer_angle = 9.0 speed_steer_angle = 9.0
steer_curve = SubResource( 21 )
max_engine_force = 280.0 max_engine_force = 280.0
max_brake_force = 95.0 max_brake_force = 95.0
throttle_power = 8000.0 throttle_power = 8000.0

View File

@ -10,8 +10,6 @@ export(float) var speed_steer_angle = 10
export(float) var max_steer_speed = 100.0 export(float) var max_steer_speed = 100.0
export(float) var max_steer_input = 80.0 export(float) var max_steer_input = 80.0
export(Curve) var steer_curve = null
export(float) var max_engine_force = 85.0 export(float) var max_engine_force = 85.0
export(float) var max_brake_force = 50.0 export(float) var max_brake_force = 50.0
export(float) var throttle_power = 6000.0 export(float) var throttle_power = 6000.0
@ -208,11 +206,6 @@ func _physics_process(delta: float):
) )
if abs(steering_input) < 0.05: if abs(steering_input) < 0.05:
steering_input = 0.0 steering_input = 0.0
elif steer_curve:
if steering_input < 0.0:
steering_input = -steer_curve.interpolate_baked(-steering_input)
else:
steering_input = steer_curve.interpolate_baked(steering_input)
var steer_speed_factor = clamp(speed / max_steer_speed, 0.0, 1.0) var steer_speed_factor = clamp(speed / max_steer_speed, 0.0, 1.0)