Compare commits

...

1 Commits

Author SHA1 Message Date
56dde7e9ed fuck manual simulation 2025-02-03 21:20:29 -05:00
4 changed files with 32 additions and 20 deletions

View File

@ -13,7 +13,7 @@ extends RigidBody3D
@export var rotation_speed: float = 0.15
@export var max_speed: float = 20.0
@export var max_rotation_speed: float = 15.0
@export var thrust_factor: float = 1.0
@export var thrust_factor: float = 2.0
@export_category("Node References")
@export var camera: Camera3D
@export var anim_player: AnimationPlayer
@ -21,6 +21,10 @@ extends RigidBody3D
@export var flip_over_timer: Timer
@export var input_suggestion_label: Label
@export var reset_point: Marker3D
@export var thrust_point_fr: Marker3D
@export var thrust_point_fl: Marker3D
@export var thrust_point_rl: Marker3D
@export var thrust_point_rr: Marker3D
var animation_initalized: bool = false
var using_joy_controller: bool = true
@ -101,27 +105,17 @@ func _integrate_forces(state):
if using_joy_controller:
if throttle_input > 0:
throttle_speed = throttle_input * 100
apply_central_force(global_transform.basis.y * throttle_speed * thrust_factor)
state.apply_force(global_transform.basis.y * throttle_input * thrust_factor, thrust_point_fr.global_position)
state.apply_force(global_transform.basis.y * throttle_input * thrust_factor, thrust_point_fl.global_position)
state.apply_force(global_transform.basis.y * throttle_input * thrust_factor, thrust_point_rr.global_position)
state.apply_force(global_transform.basis.y * throttle_input * thrust_factor, thrust_point_rl.global_position)
linear_velocity.x = clampf(linear_velocity.x, -max_speed, max_speed)
linear_velocity.y = clampf(linear_velocity.y, -100.0, max_speed)
linear_velocity.z = clampf(linear_velocity.z, -max_speed, max_speed)
#linear_velocity.x = clampf(linear_velocity.x, -max_speed, max_speed)
#linear_velocity.y = clampf(linear_velocity.y, -100.0, max_speed)
#linear_velocity.z = clampf(linear_velocity.z, -max_speed, max_speed)
# Speed scale adjusted for animation
anim_player.speed_scale = throttle_input * 4
anim_player.speed_scale = clampf(anim_player.speed_scale, 1.0, 4.0)
if yaw_input != 0:
rotate_object_local(Vector3.UP, yaw_input * rotation_speed) # Y axis rotation
if roll_input != 0:
rotate_object_local(Vector3.FORWARD, roll_input * rotation_speed) # Z axis rotation
if pitch_input != 0:
rotate_object_local(Vector3.RIGHT, pitch_input * rotation_speed) # X axis rotation
# Damping
if yaw_input == 0:
state.angular_velocity.y = lerp(state.angular_velocity.y, 0.0, 0.05)
if roll_input == 0:
state.angular_velocity.z = lerp(state.angular_velocity.z, 0.0, 0.05)
if pitch_input == 0:
state.angular_velocity.x = lerp(state.angular_velocity.x, 0.0, 0.05)
# Rotation

View File

@ -1084,7 +1084,7 @@ shader_parameter/scanline_thickness = 0.5
shader_parameter/scanlines_spacing = 1.0
shader_parameter/noise_texture = ExtResource("10_ylv8e")
[node name="Drone" type="RigidBody3D" node_paths=PackedStringArray("camera", "anim_player", "flip_over_detection_ray", "flip_over_timer", "input_suggestion_label")]
[node name="Drone" type="RigidBody3D" node_paths=PackedStringArray("camera", "anim_player", "flip_over_detection_ray", "flip_over_timer", "input_suggestion_label", "thrust_point_fr", "thrust_point_fl", "thrust_point_rl", "thrust_point_rr")]
collision_layer = 2
collision_mask = 7
mass = 0.6
@ -1097,6 +1097,10 @@ anim_player = NodePath("AnimationPlayer")
flip_over_detection_ray = NodePath("FlipOverDetectionRay")
flip_over_timer = NodePath("FlipOverTimer")
input_suggestion_label = NodePath("VisualComponets/CameraPivot/Camera3D/CanvasLayer/HUD/VBoxContainer/HBoxContainer/MarginContainer/InputSuggestionLabel")
thrust_point_fr = NodePath("VisualComponets/Propellers/ThrustPointFR")
thrust_point_fl = NodePath("VisualComponets/Propellers/ThrustPointFL")
thrust_point_rl = NodePath("VisualComponets/Propellers/ThrustPointRL")
thrust_point_rr = NodePath("VisualComponets/Propellers/ThrustPointRR")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
@ -1234,6 +1238,7 @@ surface_material_override/0 = ExtResource("2_phv8m")
[node name="battery" type="MeshInstance3D" parent="VisualComponets"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 8, 0, 13.1, 0)
visible = false
mesh = SubResource("ArrayMesh_v7fro")
skeleton = NodePath("")
surface_material_override/0 = ExtResource("4_0xsmy")
@ -1304,6 +1309,18 @@ mesh = SubResource("ArrayMesh_71i3b")
skeleton = NodePath("")
surface_material_override/0 = ExtResource("4_ltc6o")
[node name="ThrustPointFR" type="Marker3D" parent="VisualComponets/Propellers"]
transform = Transform3D(0.163188, 0, 0, 0, 0.163188, 0, 0, 0, 0.163188, -21.6181, 7.31745, 18.168)
[node name="ThrustPointFL" type="Marker3D" parent="VisualComponets/Propellers"]
transform = Transform3D(-0.163188, 0, 0, 0, 0.163188, 4.13711e-07, 0, -4.13711e-07, 0.163188, 21.6121, 7.31745, 18.1964)
[node name="ThrustPointRL" type="Marker3D" parent="VisualComponets/Propellers"]
transform = Transform3D(0.163188, 0, 0, 0, 0.163188, 0, 0, 0, 0.163188, 21.655, 7.31745, -18.1665)
[node name="ThrustPointRR" type="Marker3D" parent="VisualComponets/Propellers"]
transform = Transform3D(-0.163188, 0, 0, 0, 0.163188, 4.13711e-07, 0, -4.13711e-07, 0.163188, -21.6181, 7.36257, -18.1559)
[node name="CameraPivot" type="Node3D" parent="VisualComponets"]
transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 4.87816, 15.4717)

View File

@ -46,6 +46,7 @@ environment = SubResource("Environment_ruppb")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.017014, 0)
[node name="Drone" parent="ResetPoint" node_paths=PackedStringArray("reset_point") instance=ExtResource("2_orkyq")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 984.979, 0)
reset_point = NodePath("..")
[node name="LOSView" type="Node3D" parent="." node_paths=PackedStringArray("drone", "child_camera")]