before planets

This commit is contained in:
Crizomb 2025-08-03 05:57:42 +02:00
parent bb6404e918
commit e09f05b566
57 changed files with 1203 additions and 90 deletions

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dycfldtocfi6a"
path="res://.godot/imported/33480__hiccupvirus__stereo-tron-bike-engine.wav-ca695db0062fc4a0abf1e4cca8d6dbaa.sample"
[deps]
source_file="res://entities/car/33480__hiccupvirus__stereo-tron-bike-engine.wav"
dest_files=["res://.godot/imported/33480__hiccupvirus__stereo-tron-bike-engine.wav-ca695db0062fc4a0abf1e4cca8d6dbaa.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=3
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2

View file

@ -28,7 +28,7 @@ var current_steer_speed = base_steer_speed
var last_steer_input := 0.0
var rotation_angle := 0.0
var respawn_pos : Vector3
var respawn_trans : Transform3D
var thread: Thread = Thread.new()
var steer_input = 0.0
@ -40,17 +40,14 @@ func custom_gravity() -> Vector3:
var closest_offset = road_path.curve.get_closest_offset(road_path.to_local(position))
var closest_transform = road_path.curve.sample_baked_with_rotation(closest_offset, true, true)
var closest_point = road_path.to_global(closest_transform.origin)
#var project_plane = Plane(closest_transform.basis.y.normalized(), closest_point)
#print(closest_point)
#return -project_plane.project(position).normalized() * 0.1
#var attractor = road_path.to_global(road_path.curve.get_closest_point(road_path.to_local(position)))
return -closest_transform.basis.y
func return_to_road():
position = respawn_pos + 3*Vector3.UP
rotation.z = 0
rotation.x = 0
var closest_offset = road_path.curve.get_closest_offset(road_path.to_local(position))
var closest_transform = road_path.curve.sample_baked_with_rotation(closest_offset, true, true)
transform = respawn_trans
position += closest_transform.basis.y * 2.0
linear_velocity = Vector3.ZERO
angular_velocity = Vector3.ZERO
@ -61,6 +58,9 @@ func _process(_delta: float) -> void:
if Input.is_action_just_pressed("restart"):
return_to_road()
if Input.is_action_just_pressed("hardRestart"):
get_tree().reload_current_scene()
func _physics_process(delta: float) -> void:
var move_input := Input.get_axis("back", "forward")
@ -68,17 +68,16 @@ func _physics_process(delta: float) -> void:
steer_input = lerpf(steer_input, steer_input_brut, 0.1)
var is_on_floor := backward_left_respawn.is_colliding() || backward_right_respawn.is_colliding() || forward_left_respawn.is_colliding() || forward_right_respawn.is_colliding()
var is_all_wheel_on_floor := backward_left_respawn.is_colliding() && backward_right_respawn.is_colliding() && forward_left_respawn.is_colliding() && forward_right_respawn.is_colliding()
var is_flat : bool = transform.basis.y.dot(Vector3.UP) > 0.9
# Doing custom gravity like a chad
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR, custom_gravity())
if is_all_wheel_on_floor && is_flat:
respawn_pos = position
if is_all_wheel_on_floor:
respawn_trans = transform
if !is_on_floor:
air_time += delta
if air_time > 1.5:
if air_time > 3:
return_to_road()
return
air_time = 0.0
@ -92,30 +91,18 @@ func _physics_process(delta: float) -> void:
# Rotation
rotation_angle = steer_input * delta
#angular_velocity = steer_input * delta * global_transform.basis.y * 30.0
rotate(global_transform.basis.y, rotation_angle)
# Drift Simulation
var velocity = linear_velocity
var forward_dir = global_transform.basis.z
if forward_dir.length_squared() == 0.0:
return # skip drift this frame if something is invalid
return
forward_dir = forward_dir.normalized()
var forward_velocity = forward_dir * velocity.dot(forward_dir)
var lateral_velocity = velocity - forward_velocity
var drift_factor = inverse_lerp(
lateral_velocity_total_drift_threshold,
lateral_velocity_start_drift_threshold,
lateral_velocity.length()
)
drift_factor = clamp(drift_factor, 0, 1)
steer_speed = lerp(steer_speed * 2.0, base_steer_speed, drift_factor)
var lateral_friction_force = -lateral_velocity * base_lateral_friction * drift_factor
var lateral_friction_force = -lateral_velocity * base_lateral_friction
apply_central_force(lateral_friction_force)

View file

@ -1,20 +1,24 @@
[gd_scene load_steps=6 format=3 uid="uid://dgs0fqojgcmu3"]
[gd_scene load_steps=7 format=3 uid="uid://dgs0fqojgcmu3"]
[ext_resource type="Script" uid="uid://ctjy0e806j0vk" path="res://entities/car/car.gd" id="1_nh45c"]
[ext_resource type="PackedScene" uid="uid://drrl25ujbosbr" path="res://entities/car/tron_moto_lowpoly/scene.gltf" id="2_1ang0"]
[ext_resource type="AudioStream" uid="uid://dycfldtocfi6a" path="res://entities/car/33480__hiccupvirus__stereo-tron-bike-engine.wav" id="3_x0apo"]
[ext_resource type="PackedScene" uid="uid://npanejthded5" path="res://entities/car/tron_moto_lowpoly/sketchfab_scene.tscn" id="4_hk7sx"]
[ext_resource type="Script" uid="uid://bggsg5iqltuk3" path="res://entities/car/motor_stream.gd" id="4_qxogl"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_1ang0"]
friction = 0.5
rough = true
absorbent = true
[sub_resource type="BoxShape3D" id="BoxShape3D_76tdi"]
size = Vector3(1, 0, 2.2)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_yotxw"]
height = 1.1
[sub_resource type="BoxShape3D" id="BoxShape3D_qxogl"]
size = Vector3(2.99533, 1, 1)
[node name="Car" type="RigidBody3D"]
mass = 10.0
physics_material_override = SubResource("PhysicsMaterial_1ang0")
continuous_cd = true
contact_monitor = true
max_contacts_reported = 4
script = ExtResource("1_nh45c")
[node name="ForwardLeft" type="RayCast3D" parent="."]
@ -29,18 +33,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.435121, 1)
[node name="BackwardLeft" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0.435121, 1)
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.1)
shape = SubResource("BoxShape3D_76tdi")
disabled = true
[node name="CollisionShape3D2" type="CollisionShape3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, -4.37114e-08, 0, -4.37114e-08, -1, -1, -4.37114e-08, 1.91069e-15, 0, 0, 1)
shape = SubResource("CylinderShape3D_yotxw")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, -4.37114e-08, 0, -4.37114e-08, -1, -1, -4.37114e-08, 1.91069e-15, 0, 0, -1.2)
shape = SubResource("CylinderShape3D_yotxw")
transform = Transform3D(-4.37114e-08, 1, -4.37114e-08, 0, -4.37114e-08, -1, -1, -4.37114e-08, 1.91069e-15, -4.73325e-08, 0, -0.08284)
shape = SubResource("BoxShape3D_qxogl")
[node name="RaycastsRespawn" type="Node3D" parent="."]
transform = Transform3D(2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0)
@ -57,12 +52,20 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 1)
[node name="BackwardLeftRespawn" type="RayCast3D" parent="RaycastsRespawn"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0, 1)
[node name="Sketchfab_Scene" parent="." instance=ExtResource("2_1ang0")]
transform = Transform3D(-0.35, 0, -3.0598e-08, 0, 0.35, 0, 3.0598e-08, 0, -0.35, 0.0317484, -0.52664, 0)
[node name="CameraFollowPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.31962, -2.93594)
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
[node name="MotorStream" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("3_x0apo")
autoplay = true
bus = &"Motor"
script = ExtResource("4_qxogl")
[node name="Sketchfab_Scene2" parent="." instance=ExtResource("4_hk7sx")]
transform = Transform3D(-0.35, 0, -5.28485e-08, 0, 0.35, 0, 5.28485e-08, 0, -0.35, 0.0317484, -0.52664, 0)
[node name="OmniLight3D" type="OmniLight3D" parent="."]
light_color = Color(0.0217323, 0.905795, 0.982301, 1)
omni_range = 3.75794
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View file

@ -0,0 +1,6 @@
extends AudioStreamPlayer3D
@onready var car: Car = $".."
func _process(delta: float) -> void:
pitch_scale = max(car.linear_velocity.length() * 0.1, 0.1)

View file

@ -0,0 +1 @@
uid://bggsg5iqltuk3

View file

@ -32,6 +32,17 @@ animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
_subresources={
"meshes": {
"Sketchfab_Scene_Object_2": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"save_to_file/enabled": true,
"save_to_file/path": ""
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1

File diff suppressed because one or more lines are too long