small racing game im working on
square collider [skip ci]
bendn 2023-03-09
parent f44cfc9 · commit 80a0d8d
-rw-r--r--assets/cars/kenney_sedan/sedan.tscn18
-rw-r--r--classes/resources/ghost_data.gd1
-rw-r--r--race.gd4
3 files changed, 10 insertions, 13 deletions
diff --git a/assets/cars/kenney_sedan/sedan.tscn b/assets/cars/kenney_sedan/sedan.tscn
index 5aa64c1..e24be28 100644
--- a/assets/cars/kenney_sedan/sedan.tscn
+++ b/assets/cars/kenney_sedan/sedan.tscn
@@ -323,8 +323,8 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_8qmjc")
-[sub_resource type="SphereShape3D" id="SphereShape3D_t532n"]
-radius = 2.0
+[sub_resource type="BoxShape3D" id="BoxShape3D_cknfd"]
+size = Vector3(2.9, 2.1, 5.5)
[node name="Sedan" type="VehicleBody3D"]
collision_layer = 2
@@ -353,7 +353,7 @@ wheel_radius = 0.7
wheel_rest_length = 0.4
wheel_friction_slip = 1.8
suspension_travel = 0.2
-suspension_stiffness = 150.0
+suspension_stiffness = 50.0
suspension_max_force = 18000.0
damping_compression = 0.8
damping_relaxation = 0.9
@@ -373,7 +373,7 @@ wheel_radius = 0.7
wheel_rest_length = 0.4
wheel_friction_slip = 1.8
suspension_travel = 0.2
-suspension_stiffness = 150.0
+suspension_stiffness = 50.0
suspension_max_force = 18000.0
damping_compression = 0.8
damping_relaxation = 0.9
@@ -395,7 +395,7 @@ wheel_radius = 0.7
wheel_rest_length = 0.4
wheel_friction_slip = 2.0
suspension_travel = 0.2
-suspension_stiffness = 150.0
+suspension_stiffness = 50.0
suspension_max_force = 18000.0
damping_compression = 0.8
damping_relaxation = 0.9
@@ -414,7 +414,7 @@ wheel_radius = 0.7
wheel_rest_length = 0.4
wheel_friction_slip = 2.0
suspension_travel = 0.2
-suspension_stiffness = 150.0
+suspension_stiffness = 50.0
suspension_max_force = 18000.0
damping_compression = 0.8
damping_relaxation = 0.9
@@ -427,8 +427,8 @@ skeleton = NodePath("")
[node name="particles" parent="fr" instance=ExtResource("4_axi2x")]
[node name="Coll" type="CollisionShape3D" parent="."]
-transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.43328, 0)
-shape = SubResource("SphereShape3D_t532n")
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.48339, 0)
+shape = SubResource("BoxShape3D_cknfd")
[node name="Engine" parent="." instance=ExtResource("4_gseqg")]
@@ -443,6 +443,4 @@ volume_db = -25.0
stream = ExtResource("19_stkh0")
volume_db = -10.0
-[node name="Camera3D" type="Camera3D" parent="."]
-
[connection signal="shifted" from="." to="Gearbox" method="_on_sedan_shifted"]
diff --git a/classes/resources/ghost_data.gd b/classes/resources/ghost_data.gd
index 8ad0915..f7c1cbc 100644
--- a/classes/resources/ghost_data.gd
+++ b/classes/resources/ghost_data.gd
@@ -38,7 +38,6 @@ func clear() -> void:
snap_count = 0
func collect(lap: int, cp: int, now: float) -> void:
- now = snappedf(now, .001) # 3dec precision
checkpoints[lap][cp] = now
snapped_checkpoints[lap][cp] = snap_count
if lap == len(checkpoints) - 1 && cp == -1:
diff --git a/race.gd b/race.gd
index 618c9f7..9007590 100644
--- a/race.gd
+++ b/race.gd
@@ -139,8 +139,8 @@ func collect(cp: int) -> void:
car.checkpoint_sound.play()
var time := best_time_data.get_time(current_lap, cp) if best_time_data else -1.0
time = best_time_data.time if (not track_res.laps or track_res.laps == current_lap + 1) and cp == -1 and time != -1.0 else time
- split.emit(timer.now(), time)
- data.collect(current_lap, cp, timer.now())
+ split.emit(snappedf(timer.now(), .001), time)
+ data.collect(current_lap, cp, snappedf(timer.now(), .001))
func start() -> void:
timer.start()